/* =========================
   CSS Variables & Reset
   ========================= */
:root {
    /* Primary Colors (Healthcare Professional Theme) */
    --primary: #2C5F7F;
    --primary-dark: #1A4059;
    --primary-light: #4A8FB5;
    --primary-pale: #E3F2FA;
    
    /* Secondary Colors */
    --bg-main: #F8FAFB;
    --bg-white: #FFFFFF;
    --bg-gradient-start: #FFFFFF;
    --bg-gradient-end: #F0F7FB;
    --text-primary: #1A2332;
    --text-secondary: #5E6C7F;
    --text-on-primary: #FFFFFF;
    --border: #D1DCE5;
    --border-light: #E8EEF3;
    --success: #34A853;
    --warning: #FBBC04;
    --error: #EA4335;
    --info: #4285F4;
    
    /* Healthcare Accent Colors */
    --accent-teal: #00BFA5;
    --accent-purple: #7B61FF;
    --accent-orange: #FF9F43;
    
    /* Emotion Colors (Professional Healthcare Palette) */
    --emotion-anger: #E57373;
    --emotion-anxiety: #FFB74D;
    --emotion-sadness: #64B5F6;
    --emotion-withdrawal: #9575CD;
    --emotion-confusion: #90A4AE;
    --emotion-calm: #81C784;
    --emotion-joy: #FFD54F;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(28, 55, 90, 0.08);
    --shadow-md: 0 4px 16px rgba(28, 55, 90, 0.12);
    --shadow-lg: 0 8px 32px rgba(28, 55, 90, 0.16);
    
    /* Spacing */
    --spacing-xs: 8px;
    --spacing-sm: 12px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Font Sizes */
    --font-xs: 12px;
    --font-sm: 13px;
    --font-base: 14px;
    --font-md: 16px;
    --font-lg: 18px;
    --font-xl: 20px;
    --font-2xl: 24px;
    --font-3xl: 28px;
    
    /* Touch Target */
    --touch-min: 44px;
    --touch-optimal: 48px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Noto Sans KR', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: var(--font-base);
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    width: 100%;
    min-height: 100vh;
    position: relative;
}

.page {
    width: 100%;
    min-height: 100vh;
    display: none;
    flex-direction: column;
}

.page.active {
    display: flex;
}

/* =========================
   Loading & Toast
   ========================= */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 90%;
    max-width: 400px;
}

.toast {
    background: var(--text-primary);
    color: white;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================
   Common Components
   ========================= */
.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

.header {
    width: 100%;
    height: 60px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--spacing-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-title {
    font-size: var(--font-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.logo-mini {
    width: 32px;
    height: 32px;
    font-size: 24px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: var(--font-md);
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
    min-height: var(--touch-optimal);
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(214, 69, 69, 0.2);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary-pale);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: none;
}

.btn-ghost:hover {
    background: var(--bg-main);
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    background: #BDC3C7;
    color: #95A5A6;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-small {
    min-height: var(--touch-min);
    font-size: var(--font-sm);
    padding: 8px 16px;
}

.btn-icon {
    width: var(--touch-min);
    height: var(--touch-min);
    padding: 0;
    border-radius: 50%;
}

/* Input Fields */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: var(--font-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    min-height: var(--touch-optimal);
    padding: 12px;
    font-size: var(--font-md);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: #F9F9F9;
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-white);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

textarea.form-input {
    min-height: 100px;
    resize: vertical;
}

.input-group {
    display: flex;
    gap: var(--spacing-sm);
}

.input-group .form-input {
    flex: 1;
}

/* Cards */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.card-selectable {
    cursor: pointer;
    border-width: 2px;
}

.card-selectable.selected {
    background: var(--primary-pale);
    border-color: var(--primary);
}

.card-title {
    font-size: var(--font-md);
    font-weight: 600;
    margin-bottom: 4px;
}

.card-description {
    font-size: var(--font-sm);
    color: var(--text-secondary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-md);
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    animation: modalSlideUp 0.3s ease;
}

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

.modal-header {
    padding: var(--spacing-lg) var(--spacing-md) var(--spacing-md);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-size: var(--font-xl);
    font-weight: 600;
}

.modal-body {
    padding: var(--spacing-lg) var(--spacing-md);
}

.modal-footer {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border);
    display: flex;
    gap: var(--spacing-sm);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 56px;
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding: 0 var(--spacing-sm);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
    cursor: pointer;
    min-height: var(--touch-min);
}

.bottom-nav-item.active {
    color: var(--primary);
}

.bottom-nav-item i {
    font-size: 20px;
}

.bottom-nav-item span {
    font-size: var(--font-xs);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-secondary {
    color: var(--text-secondary);
}

.text-error {
    color: var(--error);
}

.text-success {
    color: var(--success);
}

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* Responsive */
@media (max-width: 599px) {
    .container {
        padding: 0 var(--spacing-md);
    }
}

@media (min-width: 600px) {
    .modal {
        max-width: 500px;
    }
}

@media (min-width: 1000px) {
    .bottom-nav {
        display: none;
    }
    
    .page {
        padding-bottom: 0;
    }
}
