/**
 * Kakehashi - Apple Style CSS
 * Support File Web Application
 */

/* ========================================
   CSS Custom Properties (Variables)
   ======================================== */

:root {
    /* Colors - Light Mode */
    --apple-blue: #007AFF;
    --apple-green: #34C759;
    --apple-indigo: #5856D6;
    --apple-orange: #FF9500;
    --apple-pink: #FF2D55;
    --apple-purple: #AF52DE;
    --apple-red: #FF3B30;
    --apple-teal: #5AC8FA;
    --apple-yellow: #FFCC00;

    /* Grays - Light Mode */
    --apple-gray: #8E8E93;
    --apple-gray-2: #AEAEB2;
    --apple-gray-3: #C7C7CC;
    --apple-gray-4: #D1D1D6;
    --apple-gray-5: #E5E5EA;
    --apple-gray-6: #F2F2F7;

    /* Backgrounds - Light Mode */
    --apple-bg-primary: #FFFFFF;
    --apple-bg-secondary: #F2F2F7;
    --apple-bg-tertiary: #FFFFFF;

    /* Text Colors */
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --text-tertiary: #aeaeb2;

    /* Typography */
    --font-thin: 100;
    --font-ultralight: 200;
    --font-light: 300;
    --font-regular: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;
    --font-heavy: 800;
    --font-black: 900;

    /* Font Sizes */
    --text-large-title: 34px;
    --text-title-1: 28px;
    --text-title-2: 22px;
    --text-title-3: 20px;
    --text-headline: 17px;
    --text-body: 17px;
    --text-callout: 16px;
    --text-subhead: 15px;
    --text-footnote: 13px;
    --text-caption-1: 12px;
    --text-caption-2: 11px;

    /* Spacing - 8pt Grid System */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;
    --spacing-3xl: 64px;
    --spacing-4xl: 96px;
    --spacing-5xl: 128px;

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

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
    --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);

    /* Animations */
    --ease-in-out: cubic-bezier(0.42, 0, 0.58, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in: cubic-bezier(0.32, 0, 0.67, 0);
    --ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);

    --duration-fast: 200ms;
    --duration-normal: 300ms;
    --duration-slow: 500ms;
    --duration-slower: 700ms;
}

/* Dark Mode Variables - System Preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --apple-blue: #0A84FF;
        --apple-green: #30D158;
        --apple-indigo: #5E5CE6;
        --apple-orange: #FF9F0A;
        --apple-pink: #FF375F;
        --apple-purple: #BF5AF2;
        --apple-red: #FF453A;
        --apple-teal: #64D2FF;
        --apple-yellow: #FFD60A;

        --apple-gray: #8E8E93;
        --apple-gray-2: #636366;
        --apple-gray-3: #48484A;
        --apple-gray-4: #3A3A3C;
        --apple-gray-5: #2C2C2E;
        --apple-gray-6: #1C1C1E;

        --apple-bg-primary: #000000;
        --apple-bg-secondary: #1C1C1E;
        --apple-bg-tertiary: #2C2C2E;

        --text-primary: #f5f5f7;
        --text-secondary: #a1a1a6;
        --text-tertiary: #636366;

        --bg-primary: #1C1C1E;
    }
}

/* Dark Mode Variables - Manual Override */
:root[data-theme="dark"] {
    --apple-blue: #0A84FF;
    --apple-green: #30D158;
    --apple-indigo: #5E5CE6;
    --apple-orange: #FF9F0A;
    --apple-pink: #FF375F;
    --apple-purple: #BF5AF2;
    --apple-red: #FF453A;
    --apple-teal: #64D2FF;
    --apple-yellow: #FFD60A;

    --apple-gray: #8E8E93;
    --apple-gray-2: #636366;
    --apple-gray-3: #48484A;
    --apple-gray-4: #3A3A3C;
    --apple-gray-5: #2C2C2E;
    --apple-gray-6: #1C1C1E;

    --apple-bg-primary: #000000;
    --apple-bg-secondary: #1C1C1E;
    --apple-bg-tertiary: #2C2C2E;

    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #636366;

    --bg-primary: #1C1C1E;
}

/* Dark mode specific overrides */
:root[data-theme="dark"] .navbar,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .navbar {
        background: rgba(28, 28, 30, 0.8);
    }
}

:root[data-theme="dark"] .card,
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .card {
        background: var(--apple-bg-tertiary);
    }
}

/* ========================================
   Reset & Base Styles
   ======================================== */

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--apple-bg-secondary);
    min-height: 100vh;
}

a {
    color: var(--apple-blue);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: #0051D5;
}

/* ========================================
   Layout
   ======================================== */

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content {
    flex: 1;
    padding: var(--spacing-lg);
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

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

/* ========================================
   Navigation Bar
   ======================================== */

.navbar {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all var(--duration-normal) var(--ease-out);
}

@media (prefers-color-scheme: dark) {
    .navbar {
        background: rgba(0, 0, 0, 0.8);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
}

.navbar-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 40px;
}

.navbar-brand {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-brand:hover {
    color: var(--text-primary);
}

.navbar-menu {
    display: flex;
    gap: 32px;
    list-style: none;
    margin: 0;
    flex: 1;
}

.navbar-menu a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 17px;
    font-weight: 500;
    transition: color var(--duration-normal) var(--ease-out);
}

.navbar-menu a:hover {
    color: var(--apple-blue);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-user-name {
    font-size: 15px;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .navbar-menu {
        display: none;
    }

    .navbar-container {
        padding: 12px 16px;
    }
}

/* ========================================
   Typography
   ======================================== */

.text-large-title {
    font-size: var(--text-large-title);
    font-weight: var(--font-bold);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.text-title-1 {
    font-size: var(--text-title-1);
    font-weight: var(--font-bold);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.text-title-2 {
    font-size: var(--text-title-2);
    font-weight: var(--font-bold);
    line-height: 1.3;
}

.text-title-3 {
    font-size: var(--text-title-3);
    font-weight: var(--font-semibold);
    line-height: 1.4;
}

.text-body {
    font-size: var(--text-body);
    font-weight: var(--font-regular);
    line-height: 1.6;
}

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

.page-title {
    font-size: clamp(28px, 5vw, 34px);
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    color: var(--text-primary);
}

.section-title {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: var(--spacing-md);
    color: var(--text-primary);
}

/* ========================================
   Cards & Containers
   ======================================== */

.card {
    background: var(--apple-bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    transition: all var(--duration-normal) var(--ease-out);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.card-flat {
    box-shadow: none;
    border: 1px solid var(--apple-gray-5);
}

.card-flat:hover {
    transform: none;
    box-shadow: none;
}

.card-glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
}

@media (prefers-color-scheme: dark) {
    .card-glass {
        background: rgba(44, 44, 46, 0.7);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-weight: var(--font-semibold);
    font-size: var(--text-body);
    border: none;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    text-decoration: none;
    text-align: center;
    font-family: inherit;
    min-height: 44px;
}

.btn-primary {
    background: var(--apple-blue);
    color: white;
}

.btn-primary:hover {
    background: #0051D5;
    transform: scale(1.02);
    color: white;
}

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

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

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

.btn-secondary:hover {
    background: var(--apple-blue);
    color: white;
    transform: scale(1.02);
}

.btn-ghost {
    background: rgba(0, 122, 255, 0.1);
    color: var(--apple-blue);
}

.btn-ghost:hover {
    background: rgba(0, 122, 255, 0.2);
}

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

.btn-danger:hover {
    background: #D93025;
    transform: scale(1.02);
    color: white;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 19px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 15px;
    min-height: 36px;
}

.btn-xs {
    padding: 6px 12px;
    font-size: 13px;
    min-height: 32px;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    .btn-icon {
        background: rgba(255, 255, 255, 0.1);
    }

    .btn-icon:hover {
        background: rgba(255, 255, 255, 0.2);
    }
}

/* ========================================
   Form Controls
   ======================================== */

.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 17px;
    border: 1px solid var(--apple-gray-4);
    border-radius: var(--radius-md);
    background: var(--apple-bg-primary);
    color: var(--text-primary);
    transition: all var(--duration-normal) var(--ease-out);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.form-control:disabled {
    background: var(--apple-gray-6);
    color: var(--apple-gray);
    cursor: not-allowed;
}

.form-control.error {
    border-color: var(--apple-red);
}

.form-control.error:focus {
    box-shadow: 0 0 0 4px rgba(255, 59, 48, 0.1);
}

.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.form-error {
    display: block;
    margin-top: 6px;
    font-size: 13px;
    color: var(--apple-red);
}

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

/* Select */
.select-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.select-wrapper select {
    width: 100%;
    padding: 12px 40px 12px 16px;
    font-size: 17px;
    border: 1px solid var(--apple-gray-4);
    border-radius: var(--radius-md);
    background: var(--apple-bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    appearance: none;
    font-family: inherit;
    transition: all var(--duration-normal) var(--ease-out);
}

.select-wrapper select:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.select-wrapper::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid var(--apple-gray);
    pointer-events: none;
}

/* Checkbox */
.checkbox {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.checkbox input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--apple-gray-4);
    border-radius: 6px;
    margin-right: 12px;
    transition: all var(--duration-normal) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.checkbox input:checked ~ .checkmark {
    background: var(--apple-blue);
    border-color: var(--apple-blue);
}

.checkmark:after {
    content: "";
    display: none;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox input:checked ~ .checkmark:after {
    display: block;
}

/* ========================================
   Tables
   ======================================== */

.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    background: var(--apple-bg-primary);
    box-shadow: var(--shadow-sm);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--apple-gray-5);
}

.table th {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--apple-gray-6);
}

.table tr:last-child td {
    border-bottom: none;
}

.table tr:hover td {
    background: var(--apple-gray-6);
}

/* ========================================
   Badges & Pills
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}

.badge-blue {
    background: rgba(0, 122, 255, 0.1);
    color: var(--apple-blue);
}

.badge-green {
    background: rgba(52, 199, 89, 0.1);
    color: var(--apple-green);
}

.badge-red {
    background: rgba(255, 59, 48, 0.1);
    color: var(--apple-red);
}

.badge-orange {
    background: rgba(255, 149, 0, 0.1);
    color: var(--apple-orange);
}

.badge-gray {
    background: rgba(142, 142, 147, 0.1);
    color: var(--apple-gray);
}

.badge-purple {
    background: rgba(175, 82, 222, 0.1);
    color: var(--apple-purple);
}

/* ========================================
   Child Card (Dashboard)
   ======================================== */

.child-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.child-card {
    background: var(--apple-bg-primary);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    transition: all var(--duration-normal) var(--ease-out);
    text-decoration: none;
    color: inherit;
    display: block;
}

.child-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    color: inherit;
}

.child-card-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.child-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--apple-blue), var(--apple-purple));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    font-weight: 600;
    flex-shrink: 0;
}

.child-info h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
}

.child-info p {
    font-size: 15px;
    color: var(--text-secondary);
}

.child-card-stats {
    display: flex;
    gap: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--apple-gray-5);
}

.stat-item {
    text-align: center;
    flex: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--apple-blue);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========================================
   Tab Navigation
   ======================================== */

.tabs {
    display: flex;
    gap: 8px;
    padding: 4px;
    background: var(--apple-gray-6);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    overflow-x: auto;
}

.tab {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    white-space: nowrap;
    text-decoration: none;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    background: var(--apple-bg-primary);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

/* ========================================
   Daily Record Cards
   ======================================== */

.record-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.record-card {
    background: var(--apple-bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration-normal) var(--ease-out);
}

.record-card:hover {
    box-shadow: var(--shadow-md);
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.record-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.record-mood {
    font-size: 24px;
}

.record-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 8px;
}

.record-content {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.record-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--apple-gray-5);
}

.record-meta {
    display: flex;
    gap: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========================================
   Alerts & Messages
   ======================================== */

.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    font-size: 15px;
}

.alert-success {
    background: rgba(52, 199, 89, 0.1);
    color: var(--apple-green);
    border-left: 4px solid var(--apple-green);
}

.alert-error {
    background: rgba(255, 59, 48, 0.1);
    color: var(--apple-red);
    border-left: 4px solid var(--apple-red);
}

.alert-warning {
    background: rgba(255, 149, 0, 0.1);
    color: var(--apple-orange);
    border-left: 4px solid var(--apple-orange);
}

.alert-info {
    background: rgba(0, 122, 255, 0.1);
    color: var(--apple-blue);
    border-left: 4px solid var(--apple-blue);
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
    text-align: center;
    padding: var(--spacing-4xl) var(--spacing-lg);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: var(--spacing-lg);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 17px;
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto var(--spacing-lg);
}

/* ========================================
   Loading Spinner
   ======================================== */

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--apple-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

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

/* ========================================
   Modal
   ======================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

.modal {
    background: var(--apple-bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    position: relative;
    animation: scaleUp var(--duration-normal) var(--ease-out);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 50%;
    font-size: 24px;
    color: var(--apple-gray);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

.modal-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-body {
    font-size: 17px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Modal as full-screen overlay (alternative structure) */
.modal:not(.modal-content) {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal:not(.modal-content).active {
    display: flex;
}

.modal .modal-content {
    background: var(--apple-bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    position: relative;
    animation: scaleUp var(--duration-normal) var(--ease-out);
}

.modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal .modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================
   Login Page
   ======================================== */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: var(--apple-bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--spacing-2xl);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-2xl);
}

.login-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.login-logo {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
}

.login-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 17px;
    color: var(--text-secondary);
}

.login-footer {
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--apple-gray-5);
    text-align: center;
}

.login-footer p {
    margin-bottom: var(--spacing-md);
    color: var(--text-secondary);
    font-size: 14px;
}

.text-link {
    color: var(--apple-blue);
    text-decoration: none;
    font-size: 14px;
}

.text-link:hover {
    text-decoration: underline;
}

/* ========================================
   Utility Classes
   ======================================== */

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

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

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

.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

.hidden { display: none; }

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .main-content {
        padding: var(--spacing-md);
    }

    .card {
        padding: var(--spacing-lg);
    }

    .child-grid {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

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

/* ========================================
   Notification Badge
   ======================================== */

.notification-bell {
    transition: transform var(--duration-fast) var(--ease-out);
}

.notification-bell:hover {
    transform: scale(1.1);
}

.notification-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--apple-red);
    color: white;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(255, 59, 48, 0.4);
}

/* ========================================
   Comments Section
   ======================================== */

.comments-section {
    margin-top: var(--spacing-xl);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--apple-gray-5);
}

/* ========================================
   Sidebar Layout (PC)
   ======================================== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-primary);
    border-right: 1px solid var(--apple-gray-5);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--duration-normal) var(--ease-out);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--apple-gray-5);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-logo {
    font-size: 28px;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-section-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 20px 12px 8px;
    margin-top: 8px;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    transition: all var(--duration-fast) var(--ease-out);
}

.sidebar-item a:hover {
    background: var(--apple-gray-6);
}

.sidebar-item.active a {
    background: var(--apple-blue);
    color: white;
}

.sidebar-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.sidebar-badge {
    margin-left: auto;
    background: var(--apple-red);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.sidebar-item.active .sidebar-badge {
    background: rgba(255, 255, 255, 0.3);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--apple-gray-5);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--apple-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-user-info {
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 12px;
    color: var(--text-secondary);
}

.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all var(--duration-fast);
}

.sidebar-logout .logout-icon {
    font-size: 18px;
}

.sidebar-logout .logout-text {
    font-weight: 500;
}

.sidebar-logout:hover {
    background: var(--apple-gray-6);
    color: var(--apple-red);
}

/* Guardian Child Sidebar Menu */
.sidebar-child-header {
    padding: 16px;
    border-bottom: 1px solid var(--apple-gray-5);
    margin-bottom: 8px;
}

.sidebar-back-link {
    font-size: 12px;
    color: var(--apple-blue);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.sidebar-back-link:hover {
    text-decoration: underline;
}

.sidebar-child-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}

.sidebar-menu-compact {
    padding: 0 8px;
}

.sidebar-menu-compact .sidebar-item a {
    padding: 10px 12px;
    font-size: 13px;
}

.sidebar-menu-compact .sidebar-icon {
    font-size: 16px;
    min-width: 24px;
}

/* Main Wrapper */
.main-wrapper {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-secondary);
}

/* Top Bar */
.topbar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--apple-gray-5);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background var(--duration-fast);
}

.topbar-btn:hover {
    background: var(--apple-gray-6);
}

/* Main Content in Sidebar Layout */
.app-layout .main-content {
    flex: 1;
    padding: 24px;
}

/* Main Footer */
.main-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 13px;
    border-top: 1px solid var(--apple-gray-5);
    background: var(--bg-primary);
}

/* Mobile Header */
.mobile-header {
    display: none;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--apple-gray-5);
    padding: 12px 16px;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
}

.mobile-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
}

.mobile-menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.mobile-menu-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all var(--duration-fast);
}

.mobile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-icon-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    text-decoration: none;
    color: var(--text-primary);
    position: relative;
}

.notification-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: var(--apple-red);
    border-radius: 50%;
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity var(--duration-normal);
}

.sidebar-overlay.active {
    opacity: 1;
}

/* ========================================
   Responsive - Mobile
   ======================================== */

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .topbar {
        display: none;
    }

    .mobile-header {
        display: flex;
    }

    .sidebar-overlay {
        display: block;
    }

    .app-layout .main-content {
        padding: 16px;
    }
}

/* Dark Mode for Sidebar */
[data-theme="dark"] .sidebar {
    background: var(--bg-primary);
    border-color: var(--apple-gray-5);
}

[data-theme="dark"] .sidebar-item a:hover {
    background: var(--apple-gray-5);
}

[data-theme="dark"] .topbar,
[data-theme="dark"] .mobile-header {
    background: var(--bg-primary);
    border-color: var(--apple-gray-5);
}

[data-theme="dark"] .main-footer {
    background: var(--bg-primary);
    border-color: var(--apple-gray-5);
}

/* Admin Sidebar Styling */
.sidebar-admin {
    background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
    border-right-color: #2a2a4a;
}

.sidebar-admin .sidebar-header {
    border-bottom-color: #2a2a4a;
}

.sidebar-admin .sidebar-brand {
    color: #ffffff;
}

.sidebar-admin .sidebar-section-title {
    color: #8888aa;
}

.sidebar-admin .sidebar-item a {
    color: #ccccdd;
}

.sidebar-admin .sidebar-item a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.sidebar-admin .sidebar-item.active a {
    background: var(--apple-purple);
    color: #ffffff;
}

.sidebar-admin .sidebar-footer {
    border-top-color: #2a2a4a;
}

.sidebar-admin .sidebar-user-name {
    color: #ffffff;
}

.sidebar-admin .sidebar-user-role {
    color: #8888aa;
}

.sidebar-admin .sidebar-logout {
    color: #8888aa;
}

.sidebar-admin .sidebar-logout:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--apple-red);
}
