/* BabyTime - Modern Mobile-First CSS */

:root {
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;

    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f1f5f9;
    --border-color: #e2e8f0;
    --border-focus: #6366f1;

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-text: #ffffff;

    --success: #10b981;
    --success-hover: #059669;
    --success-light: #ecfdf5;
    --success-text: #065f46;

    --danger: #ef4444;
    --danger-hover: #dc2626;
    --danger-light: #fef2f2;
    --danger-text: #991b1b;

    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --warning-text: #92400e;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-page: #0f172a;
        --bg-surface: #1e293b;
        --bg-surface-alt: #334155;
        --border-color: #334155;
        --border-focus: #818cf8;

        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;

        --primary: #6366f1;
        --primary-hover: #4f46e5;
        --primary-light: #1e1b4b;
        --primary-text: #ffffff;

        --success: #10b981;
        --success-hover: #059669;
        --success-light: #064e3b;
        --success-text: #6ee7b7;

        --danger: #ef4444;
        --danger-hover: #dc2626;
        --danger-light: #450a0a;
        --danger-text: #fca5a5;

        --warning: #f59e0b;
        --warning-light: #451a03;
        --warning-text: #fcd34d;

        --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
        --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
        --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    overflow-x: hidden;
    overflow-y: auto;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Offline Banner */
.offline-banner {
    display: none;
    background-color: var(--danger);
    color: #ffffff;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1000;
}
.offline-banner.active {
    display: block;
}

/* Header & Shell */
.app-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.role-pill {
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background-color: var(--primary-light);
    color: var(--primary);
}

.header-logout-btn {
    margin-left: 8px;
    font-size: 0.8125rem;
    padding: 4px 10px;
    min-height: 28px;
}
.header-logout-btn:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* Main Content Area */
.app-container {
    flex: 1;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
    padding: 16px 16px calc(110px + var(--safe-area-bottom)) 16px;
}

/* Auth Screens */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 400px;
    margin: auto;
}

.auth-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    box-shadow: var(--shadow-md);
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo {
    color: var(--primary);
    margin-bottom: 8px;
}

.auth-title {
    font-size: 1.625rem;
    font-weight: 800;
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    font-size: 1rem;
    font-family: inherit;
    background-color: var(--bg-surface-alt);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    user-select: none;
}

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

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

.btn-success {
    background-color: var(--success);
    color: #ffffff;
}
.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}
.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.btn-outline:hover {
    background-color: var(--bg-surface-alt);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 0.8125rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Big Hero Timer / Shift Action */
.hero-shift-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px 20px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.hero-status-title {
    font-size: 0.9375rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.live-timer-display {
    font-family: var(--font-mono);
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-primary);
    margin: 12px 0 6px 0;
    letter-spacing: -0.02em;
}

.live-timer-display.text-off-duty {
    font-family: var(--font-sans);
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: normal;
}

.status-indicator-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--success);
    margin-right: 6px;
    vertical-align: middle;
    animation: statusPulse 2s infinite ease-in-out;
}

@keyframes statusPulse {
    0% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(0.9); opacity: 0.7; }
}

.hero-subtext {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.btn-big-shift {
    width: 100%;
    max-width: 320px;
    min-height: 56px;
    font-size: 1.125rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    margin: 0 auto;
    box-shadow: var(--shadow-md);
}

/* Metric Cards & Summary Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.metric-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.metric-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.03em;
    margin-bottom: 4px;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

.metric-sub {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.metric-card.highlight {
    background-color: var(--primary-light);
    border-color: rgba(99, 102, 241, 0.3);
}
.metric-card.highlight .metric-value {
    color: var(--primary);
}

/* Section Header */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 20px 0 12px 0;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 700;
}

/* List Items / Cards */
.item-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.item-date {
    font-size: 0.9375rem;
    font-weight: 700;
}

.item-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active { background-color: var(--warning-light); color: var(--warning-text); }
.badge-completed { background-color: var(--success-light); color: var(--success-text); }
.badge-voided { background-color: var(--danger-light); color: var(--danger-text); text-decoration: line-through; }

.item-middle {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.item-amount {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 1rem;
}

.item-note {
    font-size: 0.8125rem;
    font-style: italic;
    color: var(--text-muted);
}

.item-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

/* Month Selector */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px 12px;
    margin-bottom: 16px;
}

.month-label {
    font-weight: 700;
    font-size: 1rem;
}

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 500;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-overlay.active {
    display: flex;
}

.modal-sheet {
    background-color: var(--bg-surface);
    width: 100%;
    max-width: 540px;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: 20px 20px calc(24px + var(--safe-area-bottom)) 20px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px 8px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: calc(74px + var(--safe-area-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    width: calc(100% - 32px);
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    font-size: 0.9375rem;
    font-weight: 600;
    margin-top: 8px;
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: auto;
}

.toast.toast-success {
    border-left: 4px solid var(--success);
}

.toast.toast-error {
    border-left: 4px solid var(--danger);
}

/* Alert Boxes */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin-bottom: 16px;
}
.alert-error {
    background-color: var(--danger-light);
    color: var(--danger-text);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Tab Navigation (Bottom Bar on Mobile) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 200;
}

.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    height: 100%;
    cursor: pointer;
    transition: color 0.15s ease;
}

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

.nav-icon {
    width: 22px;
    height: 22px;
}

/* View switching */
.view-section {
    display: none;
    padding-bottom: 32px;
}
.view-section.active {
    display: block;
}

#btn-logout {
    margin-top: 24px;
    margin-bottom: 60px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state-icon {
    margin-bottom: 12px;
    color: var(--text-muted);
}

/* Desktop enhancements */
@media (min-width: 768px) {
    .app-container {
        padding: 24px 20px calc(120px + var(--safe-area-bottom)) 20px;
    }
    .modal-sheet {
        border-radius: var(--radius-lg);
        margin: auto;
    }
    .modal-overlay {
        align-items: center;
    }
}
