/* 
   구독 관리 및 절감 추천 플랫폼 UI 디자인 시스템
   Theme: Sleek Dark Glassmorphism
*/

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600&display=swap');

:root {
    --bg-primary: #020617;
    --bg-secondary: #0b1329;
    --card-bg: rgba(15, 23, 42, 0.45);
    --card-border: rgba(255, 255, 255, 0.06);
    --card-hover-bg: rgba(30, 41, 59, 0.6);
    --card-hover-border: rgba(168, 85, 247, 0.3);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary-gradient: linear-gradient(135deg, #8b5cf6, #3b82f6);
    --secondary-gradient: linear-gradient(135deg, #10b981, #06b6d4);
    --accent-orange: linear-gradient(135deg, #f97316, #e11d48);
    
    --accent-purple: #a855f7;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #f43f5e;
    
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    --transition-smooth: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 10px 30px -10px rgba(0, 0, 0, 0.7);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-body);
}

body {
    background: radial-gradient(circle at top, #0f172a 0%, #020617 80%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* 폰트 헤더 일괄 적용 */
h1, h2, h3, h4, h5, h6, .brand-name {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* 스크롤바 디자인 */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-purple);
}

/* 레이아웃 구조 */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* 사이드바 */
.sidebar {
    width: 260px;
    background: rgba(2, 6, 23, 0.8);
    border-right: 1px solid var(--card-border);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
}

.brand-logo {
    width: 36px;
    height: 36px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.25rem;
    color: white;
    box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition-smooth);
    cursor: pointer;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border-left: 3px solid var(--accent-purple);
    padding-left: calc(1rem - 3px);
}

.nav-item.active {
    background: rgba(139, 92, 246, 0.15);
    border-left-color: var(--accent-purple);
}

.user-profile {
    margin-top: auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-email {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 메인 콘텐츠 영역 */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2.5rem;
}

/* 헤더 */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

.welcome-msg h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.welcome-msg p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.action-btn {
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.25);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

/* 탭 전환 구조 */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 글래스모피즘 카드 공통 */
.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-premium);
    transition: var(--transition-smooth);
}

.glass-card:hover {
    border-color: var(--card-hover-border);
    background: var(--card-hover-bg);
}

/* 요약 그리드 */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.summary-card {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.summary-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--primary-gradient);
}

.summary-card.saving::before {
    background: var(--secondary-gradient);
}

.summary-card.alert::before {
    background: var(--accent-orange);
}

.summary-title {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-value {
    font-size: 1.85rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.summary-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* 2단 메인 레이아웃 */
.content-grid {
    display: grid;
    grid-template-columns: 1.8fr 1.2fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .content-grid {
        grid-template-columns: 1fr;
    }
}

/* 분석 입력 영역 */
.analysis-input-area {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.sms-textarea {
    width: 100%;
    height: 150px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1rem;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.9rem;
    resize: none;
    transition: var(--transition-smooth);
}

.sms-textarea:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.25);
}

/* 탐지 후보 카드 그리드 */
.candidates-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.candidate-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    transition: var(--transition-smooth);
}

.candidate-card:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--card-hover-border);
}

.svc-info-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.svc-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.svc-icon-wrapper-relative {
    position: relative;
    width: 48px;
    height: 48px;
}

.svc-icon-img {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.08);
    padding: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--transition-smooth);
}

.svc-icon-img:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--accent-purple);
}

.svc-detail-text {
    display: flex;
    flex-direction: column;
}

.svc-name-title {
    font-size: 1.05rem;
    font-weight: 600;
}

.svc-score-badge {
    align-self: flex-start;
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    margin-top: 0.25rem;
    font-weight: 500;
}

.score-confirmed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.score-check {
    background: rgba(249, 115, 22, 0.15);
    color: #f97316;
    border: 1px solid rgba(249, 115, 22, 0.3);
}

.candidate-price {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.price-text {
    font-size: 1.15rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.cycle-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-confirm {
    background: var(--secondary-gradient);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-left: 1rem;
}

.btn-confirm:hover {
    transform: scale(1.05);
}

/* 내 구독 리스트 */
.subscription-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sub-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.3);
    border: 1px solid var(--card-border);
    transition: var(--transition-smooth);
}

.sub-item:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.sub-item.inactive {
    opacity: 0.5;
}

.btn-delete {
    background: rgba(244, 63, 94, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(244, 63, 94, 0.2);
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: var(--transition-smooth);
}

.btn-delete:hover {
    background: var(--accent-red);
    color: white;
}

/* 절감 추천 카드 디자인 */
.recommends-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.recommend-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.recommend-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--secondary-gradient);
    color: white;
    font-size: 0.75rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-weight: 600;
}

.saving-comparison {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

.saving-comparison .old-price {
    text-decoration: line-through;
    color: var(--text-muted);
}

.saving-comparison .new-price {
    color: var(--accent-green);
    font-weight: 700;
}

.btn-convert {
    background: var(--secondary-gradient);
    border: none;
    color: white;
    width: 100%;
    padding: 0.75rem;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn-convert:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* 폼 디자인 */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.form-control {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    color: white;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-purple);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* 캘린더/일정 섹션 */
.calendar-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.calendar-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.01);
    border-left: 3px solid var(--accent-blue);
}

.date-badge {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* 커스텀 SVG 차트 스타일 */
.chart-container {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 200px;
    margin-top: 1rem;
}

.donut-svg {
    transform: rotate(-90deg);
}

.donut-segment {
    transition: stroke-dasharray 0.5s ease-out;
}

.chart-center-text {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
}

.chart-center-val {
    font-size: 1.5rem;
    font-weight: 700;
}

.chart-center-lbl {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    align-items: center;
}

.legend-color-lbl {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* 로딩 오버레이 */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1.5rem;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(139, 92, 246, 0.15);
    border-top-color: var(--accent-purple);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 모달 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 500;
    align-items: center;
    justify-content: center;
}

.modal-content {
    width: 90%;
    max-width: 500px;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 로그인 화면 */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    background: radial-gradient(circle at top, #0f172a 0%, #020617 80%);
    z-index: 999;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-toggle {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-toggle span {
    color: var(--accent-purple);
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
}

/* 서비스 선택 모달 커스텀 스타일 */
.modal-cat-badge {
    padding: 0.4rem 1rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    color: var(--text-secondary);
    white-space: nowrap;
}

.modal-cat-badge:hover, .modal-cat-badge.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
}

.modal-svc-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: var(--transition-smooth);
    text-align: center;
}

.modal-svc-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent-purple);
    transform: translateY(-2px);
}

.modal-svc-card img {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    object-fit: contain;
    background: rgba(255, 255, 255, 0.08);
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-svc-card .svc-name {
    font-size: 0.85rem;
    font-weight: 600;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modal-svc-card .svc-price {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
