/* ═══ CSS VARIABLES & THEMING ═══ */
:root {
    /* Dark Theme (Default) */
    --bg-base: #0f1015;
    --bg-panel: rgba(25, 27, 35, 0.6);
    --bg-panel-hover: rgba(35, 38, 48, 0.8);
    
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --text-muted: #6c757d;
    
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-danger: #ef4444;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --glass-blur: blur(12px);
    
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
    
    --transition: all 0.2s ease;
}

[data-theme="light"] {
    --bg-base: #f1f5f9;
    --bg-panel: rgba(255, 255, 255, 0.7);
    --bg-panel-hover: rgba(255, 255, 255, 0.95);
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    
    --accent-primary: #2563eb;
    --accent-primary-hover: #1d4ed8;
    --accent-danger: #dc2626;
    
    --border-color: rgba(0, 0, 0, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --glass-blur: blur(12px);
}

/* ═══ RESET & BASE ═══ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, select, textarea {
    font-family: inherit;
    width: 100%;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
}
[data-theme="light"] input, 
[data-theme="light"] select, 
[data-theme="light"] textarea {
    background: rgba(255, 255, 255, 0.5);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.hidden {
    display: none !important;
}

/* ═══ UTILITIES & COMPONENTS ═══ */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--glass-shadow);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition);
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}
.btn-primary:hover {
    background-color: var(--accent-primary-hover);
    transform: translateY(-1px);
}

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

.btn-text {
    color: var(--accent-primary);
    font-weight: 600;
}
.btn-text:hover {
    text-decoration: underline;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: var(--transition);
    color: var(--text-secondary);
}
.btn-icon:hover {
    background: rgba(128, 128, 128, 0.1);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
    text-transform: uppercase;
}
.avatar.large {
    width: 64px;
    height: 64px;
    font-size: 1.5rem;
}

/* ═══ LOADERS ═══ */
.full-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-base);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.section-loader {
    padding: 40px;
    display: flex;
    justify-content: center;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.spinner.small {
    width: 24px;
    height: 24px;
    border-width: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ LAYOUTS ═══ */
.view-layer {
    min-height: 100vh;
    width: 100%;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Auth View ── */
#auth-view {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 50% -20%, rgba(59, 130, 246, 0.15) 0%, var(--bg-base) 70%);
}

.auth-box {
    width: 100%;
    max-width: 400px;
    padding: 40px 30px;
    text-align: center;
}

.auth-header {
    margin-bottom: 30px;
}
.auth-icon-wrap {
    font-size: 3rem;
    margin-bottom: 10px;
}
.auth-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 5px;
}
.auth-header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.auth-actions {
    margin-top: 30px;
}
.auth-error {
    color: var(--accent-danger);
    font-size: 0.85rem;
    margin-top: 15px;
    min-height: 20px;
}
.auth-toggle {
    margin-top: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ── App Header ── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-top: none;
}
.header-left .logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.2rem;
}
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
#user-profile {
    cursor: pointer;
}

/* ── Main Content ── */
.main-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.dashboard-header, .pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.dashboard-header h2, .pane-header h3 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.7;
}

/* Dashboard Trips Grid */
.trips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.trip-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: var(--transition);
}
.trip-card:hover {
    background: var(--bg-panel-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.trip-card h3 {
    margin-bottom: 5px;
    font-size: 1.1rem;
}
.trip-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Trip Subheader */
.trip-subheader {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    margin-bottom: 20px;
}
.trip-title-area h2 {
    font-size: 1.2rem;
    line-height: 1.2;
}
.trip-dates {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
#btn-trip-settings {
    margin-left: auto;
}

/* Trip Nav Tabs */
.trip-nav {
    display: flex;
    padding: 8px;
    gap: 8px;
    margin-bottom: 20px;
}
.nav-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 10px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
}
.nav-tab.active {
    background: var(--accent-primary);
    color: white;
}

/* Tab Content */
.tab-pane {
    display: none;
    animation: fadeIn 0.2s ease;
}
.tab-pane.active {
    display: block;
}

.content-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Packing & Itinerary Items */
.list-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    gap: 15px;
}

/* Custom Checkbox */
.checkbox {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 2px solid var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.checkbox.checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}
.checkbox svg {
    color: white;
    width: 14px;
    height: 14px;
    opacity: 0;
    transform: scale(0.5);
    transition: var(--transition);
}
.checkbox.checked svg {
    opacity: 1;
    transform: scale(1);
}

.item-content {
    flex: 1;
}
.item-title {
    font-weight: 500;
}
.item-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.assigned-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    background: rgba(128,128,128,0.2);
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

.item-actions {
    display: flex;
    gap: 5px;
}
.btn-delete {
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 5px;
}
.btn-delete:hover {
    color: var(--accent-danger);
}

/* Expenses Specific */
.expense-summary-card {
    padding: 20px;
    margin-bottom: 20px;
}
.summary-total {
    text-align: center;
    margin-bottom: 15px;
}
.summary-total span {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.summary-total h3 {
    font-size: 2.5rem;
    color: var(--accent-primary);
}
.summary-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--border-color);
    padding-top: 15px;
}
.breakdown-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
}
.expense-item .item-amount {
    font-weight: 700;
    color: var(--accent-primary);
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-container {
    width: 100%;
    max-width: 400px;
    background: var(--bg-base);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes modalPop {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}
.modal-body {
    padding: 20px;
}
.profile-container {
    max-width: 300px;
}
.profile-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}
.toast {
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    animation: toastUp 0.3s ease forwards;
}
.toast.error {
    border-color: var(--accent-danger);
}
@keyframes toastUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .trip-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        border-radius: 0;
        border-bottom: none;
        border-left: none;
        border-right: none;
        z-index: 90;
        padding: 10px 15px;
        padding-bottom: env(safe-area-inset-bottom, 15px);
    }
    .main-content {
        padding-bottom: 80px;
    }
}
