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

:root {
    --primary: #00236f;
    --primary-container: #1E3A8A;
    --secondary: #0058be;
    --secondary-container: #3B82F6;
    --success: #059669;
    --success-container: #10B981;
    --error: #ba1a1a;
    --bg-color: #f4f3fa;
    --surface: #ffffff;
    --surface-variant: #eeedf4;
    --text-main: #000000;
    --text-muted: #666666;
    --brand-gradient: linear-gradient(135deg, #1E3A8A, #3B82F6);
    --success-gradient: linear-gradient(135deg, #10B981, #059669);
    --border-color: #e0e0e0;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #020617;
        --surface: #0F172A;
        --surface-variant: #1e293b;
        --text-main: #ffffff;
        --text-muted: #94a3b8;
        --border-color: #334155;
    }
}

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

body {
    font-family: 'Hanken Grotesk', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow-x: hidden;
    padding-bottom: calc(env(safe-area-inset-bottom) + 80px); /* For bottom nav */
}

/* Typography */
h1, h2, h3 { font-weight: 700; margin-bottom: 0.5rem; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

/* App Container */
#app {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    position: relative;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}
.form-control {
    width: 100%;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--surface);
    color: var(--text-main);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--secondary-container); }

/* Buttons */
.btn {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.2s;
    font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--brand-gradient); color: white; }
.btn-text { background: transparent; color: var(--secondary-container); padding: 8px; }

/* PIN Keypad */
.pin-display {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin: 2rem 0;
}
.pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--primary-container);
    transition: background-color 0.2s;
}
.pin-dot.filled { background-color: var(--primary-container); }

.keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    max-width: 300px;
    margin: 0 auto 2rem;
}
.keypad-btn {
    background: var(--surface);
    border: none;
    border-radius: 50%;
    width: 72px;
    height: 72px;
    font-size: 24px;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.1s, background-color 0.2s;
}
.keypad-btn:active { transform: scale(0.92); background-color: var(--surface-variant); }
.keypad-btn.empty { background: transparent; box-shadow: none; cursor: default; }

/* Tabs */
.tabs {
    display: flex;
    background: var(--surface);
    border-radius: 16px;
    padding: 4px;
    margin-bottom: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    border-radius: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}
.tab.active { background: var(--surface-variant); color: var(--primary-container); }
.tab .badge { background: var(--error); color: white; padding: 2px 6px; border-radius: 10px; font-size: 12px; }

/* List Items */
.item-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: opacity 0.3s;
}
.item-card.completed { opacity: 0.6; }
.item-card.completed .item-name { text-decoration: line-through; }

.item-checkbox {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.item-card.completed .item-checkbox {
    background: var(--success-gradient);
    border-color: transparent;
    color: white;
}
.item-checkbox .material-symbols-outlined { font-size: 16px; opacity: 0; }
.item-card.completed .item-checkbox .material-symbols-outlined { opacity: 1; }

.item-content { flex: 1; }
.item-name { font-weight: 600; font-size: 16px; margin-bottom: 4px; }
.item-meta { display: flex; gap: 8px; font-size: 12px; color: var(--text-muted); align-items: center; }
.item-chip { background: var(--surface-variant); padding: 4px 8px; border-radius: 8px; display: flex; align-items: center; gap: 4px; }

/* FAB */
.fab {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + 80px);
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--brand-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(30,58,138,0.4);
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 100;
}
.fab:active { transform: scale(0.95); }

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    display: flex;
    padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 99;
}
.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    gap: 4px;
}
.nav-item.active { color: var(--primary-container); }

/* Toast */
.toast-container {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--surface-variant);
    color: var(--text-main);
    padding: 12px 24px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    animation: slideDown 0.3s ease-out forwards;
}
.toast.error { background: var(--error); color: white; }
.toast.success { background: var(--success-container); color: white; }

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state .material-symbols-outlined { font-size: 64px; margin-bottom: 16px; opacity: 0.5; }

/* Segmented Control */
.segmented-control {
    display: flex;
    background: var(--surface-variant);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 16px;
}
.segment {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-muted);
}
.segment.active { background: var(--surface); color: var(--text-main); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

/* Loader */
.loader {
    border: 3px solid var(--surface-variant);
    border-top: 3px solid var(--primary-container);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Update Modal */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal-content {
    background: var(--surface);
    padding: 24px;
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    text-align: center;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-top: 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.autocomplete-item:last-child {
    border-bottom: none;
}
.autocomplete-item:hover {
    background: var(--surface-variant);
}
.autocomplete-item .item-title {
    font-weight: 600;
}
.autocomplete-item .item-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* Paste List Textarea */
.paste-textarea {
    width: 100%;
    height: 150px;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--surface);
    color: var(--text-main);
    font-size: 16px;
    font-family: inherit;
    outline: none;
    resize: none;
    margin-bottom: 16px;
}

/* Speed Dial / Secondary FAB */
.fab-container {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + 80px);
    right: 24px;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 16px;
    z-index: 100;
}
.fab-container .fab {
    position: static; /* Override default fab position if inside container */
}
.fab-secondary {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: var(--surface);
    color: var(--primary-container);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s;
}
.fab-secondary:active { transform: scale(0.95); }

/* Confirmation Photo Bottom Sheet */
.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-radius: 24px 24px 0 0;
    padding: 24px;
    box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
    z-index: 2000;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.bottom-sheet.open {
    transform: translateY(0);
}
.bottom-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.photo-preview {
    width: 100%;
    max-height: 250px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 16px;
}

/* Status Badges */
.badge-status {
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}
.badge-pending { background: #fff3e0; color: #e65100; }
.badge-approved { background: #e8f5e9; color: #2e7d32; }
.badge-rejected { background: #ffebee; color: #c62828; }

/* Offline Banner */
.offline-banner {
    background: #ff9800;
    color: white;
    text-align: center;
    padding: 8px;
    font-size: 14px;
    font-weight: 600;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3000;
    display: none;
}
.offline-banner.visible {
    display: block;
}

/* PWA Installation Bar */
.pwa-install-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #00236f, #2563eb);
    color: white;
    padding: 12px 16px;
    border-radius: 14px;
    margin: 12px auto;
    max-width: 600px;
    box-shadow: 0 4px 16px rgba(0, 35, 111, 0.2);
    gap: 12px;
}
.pwa-install-bar-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}
.pwa-install-btn {
    background: #ffffff;
    color: #00236f;
    font-weight: 700;
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.1s ease;
}
.pwa-install-btn:active {
    transform: scale(0.95);
}
