/*
 * CareByVoice Unified Design System
 * Apple-style minimal / White + Light Gray + Charcoal / One accent color
 * 2026-03-29
 */

/* 줌/확대 방지 (iOS + Android) */
html { touch-action: manipulation; -ms-touch-action: manipulation; -webkit-text-size-adjust: 100%; -moz-text-size-adjust: 100%; text-size-adjust: 100%; }
body { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
* { -webkit-touch-callout: none; }

/* ===========================
   1. CSS Variables
   =========================== */
:root {
    /* Colors - Grayscale base */
    --white: #FFFFFF;
    --bg-primary: #F5F5F7;
    --bg-secondary: #E8E8ED;
    --border-color: #D2D2D7;
    --text-tertiary: #86868B;
    --text-secondary: #6E6E73;
    --text-primary: #1D1D1F;
    --charcoal: #1D1D1F;

    /* Accent - Single point color */
    --accent: #4A90E2;
    --accent-light: #E8F2FC;
    --accent-dark: #3A7BD5;

    /* Semantic */
    --success: #34C759;
    --success-light: #E8FAF0;
    --warning: #FF9500;
    --warning-light: #FFF4E6;
    --danger: #FF3B30;
    --danger-light: #FFF0EF;

    /* CCI Score Colors */
    --cci-excellent: #34C759;
    --cci-good: #A8D86E;
    --cci-normal: #FFD60A;
    --cci-warning: #FF9500;
    --cci-danger: #FF3B30;

    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
    --font-size-xs: 12px;
    --font-size-sm: 14px;
    --font-size-base: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 28px;

    /* Senior-specific (24pt+) */
    --font-size-senior: 24px;
    --font-size-senior-lg: 28px;
    --font-size-senior-xl: 32px;

    /* Spacing (8px grid) */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.12);

    /* Transitions */
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   2. Reset & Base
   =========================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
}

img {
    max-width: 100%;
    height: auto;
}

/* ===========================
   3. Typography
   =========================== */
h1 { font-size: var(--font-size-3xl); font-weight: 700; letter-spacing: -0.5px; }
h2 { font-size: var(--font-size-2xl); font-weight: 700; letter-spacing: -0.3px; }
h3 { font-size: var(--font-size-xl); font-weight: 600; }
h4 { font-size: var(--font-size-lg); font-weight: 600; }

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }

/* ===========================
   4. Layout
   =========================== */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 var(--space-md);
}

.container-wide {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--white);
    max-width: 600px;
    margin: 0 auto;
}

/* Admin uses full width */
.page-wrapper-admin {
    min-height: 100vh;
    background: var(--bg-primary);
    max-width: 100%;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ===========================
   5. Buttons
   =========================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    line-height: 1;
}

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

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

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1.5px solid var(--border-color);
}
.btn-outline:hover { background: var(--bg-primary); border-color: var(--text-tertiary); }

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

.btn-success-fill {
    background: var(--success);
    color: var(--white);
}

.btn-danger-fill {
    background: var(--danger);
    color: var(--white);
}

/* Senior buttons - larger */
.btn-senior {
    padding: 18px 32px;
    font-size: var(--font-size-senior);
    border-radius: var(--radius-lg);
    min-height: 64px;
}

.btn-block {
    width: 100%;
}

/* ===========================
   6. Cards
   =========================== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--bg-secondary);
}

.card-flat {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid var(--bg-secondary);
}

/* ===========================
   7. Forms
   =========================== */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.3px;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.6;
}

.form-input-senior {
    padding: 18px 20px;
    font-size: var(--font-size-senior);
    border-radius: var(--radius-lg);
}

.form-hint {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

/* Radio & Checkbox */
.form-choice {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.form-choice-item {
    flex: 1;
    min-width: 100px;
}

.form-choice-item input[type="radio"],
.form-choice-item input[type="checkbox"] {
    display: none;
}

.form-choice-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
}

.form-choice-item input:checked + .form-choice-label {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

/* ===========================
   8. Page Header
   =========================== */
.page-header {
    padding: var(--space-lg) var(--space-md);
    background: var(--white);
    border-bottom: 1px solid var(--bg-secondary);
}

.page-header-title {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--text-primary);
}

.page-header-subtitle {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

/* ===========================
   9. Navigation / Tabs
   =========================== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--bg-secondary);
    background: var(--white);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab-item {
    flex: 1;
    padding: 14px 16px;
    text-align: center;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-tertiary);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    white-space: nowrap;
}

.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* ===========================
   10. Status Badges
   =========================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
    line-height: 1;
}

.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-muted { background: var(--bg-secondary); color: var(--text-tertiary); }

/* ===========================
   11. Modal
   =========================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: cbv-fadeIn 0.25s ease;
}

.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: var(--shadow-xl);
    animation: cbv-slideUp 0.3s ease;
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--bg-secondary);
}

.modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.modal-body {
    padding: var(--space-lg);
    overflow-y: auto;
}

.modal-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--bg-secondary);
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.modal-close:hover { background: var(--bg-secondary); }

/* ===========================
   12. Tables (Admin)
   =========================== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.table th {
    background: var(--bg-primary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--bg-secondary);
    color: var(--text-primary);
}

.table tr:hover td {
    background: var(--bg-primary);
}

/* ===========================
   13. Score / CCI Components
   =========================== */
.score-circle {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--white);
}

.score-excellent { background: var(--cci-excellent); }
.score-good { background: var(--cci-good); }
.score-normal { background: var(--cci-normal); color: var(--text-primary); }
.score-warning { background: var(--cci-warning); }
.score-danger { background: var(--cci-danger); }

.score-bar {
    height: 6px;
    border-radius: 3px;
    background: var(--bg-secondary);
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* ===========================
   14. Dashboard Components
   =========================== */
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    border: 1px solid var(--bg-secondary);
    text-align: center;
}

.stat-value {
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    margin-top: var(--space-xs);
}

.heart-status {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}

.heart-active { color: var(--danger); }
.heart-inactive { color: var(--border-color); opacity: 0.4; }

/* Notification list */
.notification-item {
    display: flex;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--bg-secondary);
}

.notification-item:last-child { border-bottom: none; }

.notification-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--accent);
    margin-top: 6px;
    flex-shrink: 0;
}

.notification-text {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    line-height: 1.5;
}

.notification-time {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* ===========================
   15. Step Indicator
   =========================== */
.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: var(--space-lg) var(--space-md);
}

.step {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: 700;
    background: var(--bg-secondary);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.step.active .step-number {
    background: var(--accent);
    color: var(--white);
}

.step.completed .step-number {
    background: var(--success);
    color: var(--white);
}

.step-label {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    white-space: nowrap;
}

.step.active .step-label { color: var(--accent); font-weight: 600; }

.step-line {
    width: 32px;
    height: 2px;
    background: var(--bg-secondary);
    margin: 0 var(--space-xs);
}

.step.completed + .step-line,
.step-line.completed {
    background: var(--success);
}

/* ===========================
   16. Alerts
   =========================== */
.alert {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    line-height: 1.5;
}

.alert-info { background: var(--accent-light); color: var(--accent-dark); }
.alert-success { background: var(--success-light); color: #1B7A3D; }
.alert-warning { background: var(--warning-light); color: #8A5A00; }
.alert-danger { background: var(--danger-light); color: #C92A20; }

/* ===========================
   17. Animations
   =========================== */
@keyframes cbv-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes cbv-fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

@keyframes cbv-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes cbv-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

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

@keyframes cbv-giftPop {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    60% { transform: scale(1.15) rotate(5deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

.animate-fadeIn { animation: cbv-fadeIn 0.3s ease; }
.animate-slideUp { animation: cbv-slideUp 0.3s ease; }

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--bg-secondary);
    border-top-color: var(--accent);
    border-radius: var(--radius-full);
    animation: cbv-spin 0.6s linear infinite;
}

/* ===========================
   18. Utilities
   =========================== */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

/* Divider */
.divider {
    height: 1px;
    background: var(--bg-secondary);
    margin: var(--space-lg) 0;
}

/* ===========================
   19. Responsive
   =========================== */
@media (max-width: 600px) {
    :root {
        --space-lg: 20px;
        --space-xl: 28px;
    }

    .container-wide {
        padding: 0 var(--space-md);
    }

    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl); }
}

/* Print */
@media print {
    body { background: white; }
    .no-print { display: none !important; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
