/* ==========================================================================
   TripSplit - Premium Glassmorphism & Modern Mobile-Responsive Design System
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(51, 65, 85, 0.8);
    --bg-input: rgba(15, 23, 42, 0.6);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-glow: rgba(99, 102, 241, 0.4);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    /* Accent Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.15);

    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);

    --info: #06b6d4;
    --info-light: rgba(6, 182, 212, 0.15);

    /* Layout & Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    
    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.3);

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Overrides */
[data-theme="light"] {
    --bg-dark: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 1);
    --bg-input: #ffffff;
    --border-color: rgba(0, 0, 0, 0.08);
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-dim: #94a3b8;
    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 90%, rgba(236, 72, 153, 0.12) 0px, transparent 50%),
        radial-gradient(at 50% 50%, rgba(16, 185, 129, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.5;
    padding-bottom: 80px;
}

/* Header & Navigation Bar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 800;
    font-size: 1.35rem;
    background: linear-gradient(135deg, #818cf8, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
}

.brand-icon {
    font-size: 1.7rem;
    -webkit-text-fill-color: initial;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

/* Trip Header Banner */
.trip-header-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-soft);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
}

.trip-header-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary), #ec4899);
}

.trip-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.trip-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.trip-meta-stats {
    display: flex;
    gap: 1.25rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.meta-stat-item {
    text-align: right;
}

.meta-stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.meta-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #38bdf8;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.grid-main-sidebar {
    display: grid;
    grid-template-columns: 1fr 390px;
    gap: 1.5rem;
}

/* Cards & Glass Containers */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.35rem;
    box-shadow: var(--shadow-soft);
    transition: var(--transition);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.15rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1;
    touch-action: manipulation;
    min-height: 40px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.btn-paypal {
    background: linear-gradient(135deg, #0070ba, #1546a0);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(0, 112, 186, 0.4);
}

.btn-danger-outline {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.btn-danger-outline:hover {
    background: var(--danger-light);
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
    min-height: 36px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
    border-radius: 50%;
}

/* Floating Action Button (Mobile Only) */
.mobile-fab {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 20px;
    z-index: 99;
    border-radius: 30px;
    padding: 0.9rem 1.4rem;
    font-size: 1rem;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.6);
}

/* Participants List */
.participant-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.participant-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.participant-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #ffffff;
    font-size: 1.1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.participant-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.participant-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.balance-pill {
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.balance-pill.positive {
    background: var(--success-light);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.balance-pill.negative {
    background: var(--danger-light);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.balance-pill.neutral {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
    border: 1px solid var(--border-color);
}

/* Expenses List & Cards */
.expense-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.expense-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.15rem;
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 1rem;
    transition: var(--transition);
}

.category-icon-box {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.expense-details .title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.15rem;
}

.expense-details .meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.expense-amount {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-main);
    text-align: right;
    white-space: nowrap;
}

/* Settlement Checklist Card */
.settlement-card {
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.95));
    border: 1px solid var(--border-color-glow);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.settlement-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    transition: var(--transition);
}

.settlement-item.settled {
    opacity: 0.55;
    background: rgba(16, 185, 129, 0.05);
    border-color: rgba(16, 185, 129, 0.3);
}

.settlement-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.settlement-flow {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    flex-wrap: wrap;
}

.arrow-icon {
    color: var(--primary);
    font-size: 1.1rem;
}

.settlement-amount {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--success);
    white-space: nowrap;
}

.settlement-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Modal Popup */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 1rem;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-dark);
    border: 1px solid var(--border-color-glow);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 540px;
    padding: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    transform: translateY(20px);
    transition: transform 0.25s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-backdrop.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.65rem;
    border-bottom: 1px solid var(--border-color);
}

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

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.1rem;
}

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

/* Set font-size 16px to prevent automatic iOS Safari zoom */
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 0.75rem 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 16px;
    outline: none;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
}

.split-options-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.split-tab {
    padding: 0.6rem 0.3rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
}

.split-tab.active {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

/* Color Circle Selection */
.color-picker-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

.color-picker-opt {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
}

.color-picker-opt.selected {
    transform: scale(1.15);
    border-color: #ffffff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Category Progress Bars */
.category-bar-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.category-bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.category-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* QR Code Display Container */
.qr-code-box {
    background: #ffffff;
    padding: 1.25rem;
    border-radius: var(--radius-md);
    display: inline-block;
    margin: 0.75rem 0;
}

/* ==========================================================================
   Responsive Breakpoints & Mobile Optimization
   ========================================================================== */

@media (max-width: 992px) {
    .grid-main-sidebar {
        grid-template-columns: 1fr;
    }
    
    .trip-header-card {
        grid-template-columns: 1fr;
        text-align: left;
    }
    
    .trip-header-card > div:last-child {
        align-items: flex-start !important;
        width: 100%;
    }
    
    .trip-meta-stats {
        width: 100%;
        justify-content: space-around;
        text-align: center;
    }

    .meta-stat-item {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem 1rem;
    }

    .brand {
        font-size: 1.2rem;
    }

    .container {
        padding: 0 0.75rem;
        margin: 1rem auto;
    }

    .trip-header-card {
        padding: 1.25rem;
        border-radius: var(--radius-lg);
    }

    .trip-title {
        font-size: 1.4rem;
    }

    .mobile-fab {
        display: inline-flex;
    }

    .split-options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .expense-card {
        grid-template-columns: auto 1fr auto;
        gap: 0.75rem;
        padding: 0.85rem;
    }

    .expense-card > div:last-child {
        grid-column: span 3;
        display: flex;
        justify-content: flex-end;
    }

    .expense-amount {
        font-size: 1.1rem;
    }

    .participant-item {
        padding: 0.75rem;
    }

    .avatar-badge {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    .modal {
        padding: 1.15rem;
        border-radius: var(--radius-lg);
    }
}

/* Print View Adjustments */
@media print {
    body {
        background: #ffffff;
        color: #000000;
    }
    .navbar, .btn, .nav-actions, .settlement-actions, .mobile-fab {
        display: none !important;
    }
    .card, .settlement-card {
        box-shadow: none;
        border: 1px solid #ccc;
        background: #fff;
        color: #000;
    }
}
