/* ================================
   CSS Variables & Reset
   ================================ */

:root {
    --primary: #4A90E2;
    --primary-dark: #357ABD;
    --secondary: #50E3C2;
    --secondary-dark: #2DBEA1;
    --accent: #F5A623;
    --accent-dark: #E09516;
    
    --surface: #FFFFFF;
    --background: #F5F7FA;
    --error: #E74C3C;
    
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --text-hint: #BDC3C7;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.15), 0 10px 10px rgba(0, 0, 0, 0.04);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    --app-bar-height: 56px;
    --bottom-nav-height: 64px;
    
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    user-select: none;
    -webkit-user-select: none;
}

/* ================================
   App Container & Layout
   ================================ */

.app-container {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    margin: 0 auto;
    background: var(--surface);
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.1);
}

/* ================================
   Top App Bar
   ================================ */

.app-bar {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--app-bar-height);
    background: var(--primary);
    color: white;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.app-bar-content {
    height: 100%;
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.app-bar-title {
    font-size: 20px;
    font-weight: 500;
    letter-spacing: 0.15px;
    flex: 1;
    text-align: center;
}

/* ================================
   Main Content
   ================================ */

.main-content {
    flex: 1;
    margin-top: var(--app-bar-height);
    margin-bottom: var(--bottom-nav-height);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: var(--background);
}


/* ================================
   Screen Management
   ================================ */

.screen {
    display: none;
    opacity: 0;
    animation: fadeIn var(--transition-base) forwards;
    padding: var(--spacing-md);
    min-height: calc(100vh - var(--app-bar-height) - var(--bottom-nav-height));
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================
   Stats Grid
   ================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.stat-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ================================
   Section Headers
   ================================ */

.section-header {
    margin-bottom: var(--spacing-md);
}

.section-title {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 0.15px;
}

/* ================================
   Trip List & Cards
   ================================ */

.trip-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.trip-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.trip-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary), var(--secondary));
}

.trip-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
}

.trip-card-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.trip-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.trip-info {
    flex: 1;
    min-width: 0;
}

.trip-destination {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.trip-dates {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.trip-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.trip-badge.upcoming {
    background: rgba(74, 144, 226, 0.1);
    color: var(--primary);
}

.trip-badge.past {
    background: rgba(127, 140, 141, 0.1);
    color: var(--text-secondary);
}

.trip-notes {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: var(--spacing-sm);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.trip-duration {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: var(--spacing-sm);
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
}

/* ================================
   Search Bar
   ================================ */

.search-bar {
    position: relative;
    margin-bottom: var(--spacing-md);
}

.search-bar svg {
    position: absolute;
    left: var(--spacing-md);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-hint);
    pointer-events: none;
}

.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    border: none;
    border-radius: var(--radius-lg);
    background: var(--surface);
    font-size: 16px;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.search-bar input:focus {
    outline: none;
    box-shadow: var(--shadow-md), 0 0 0 2px var(--primary);
}

.search-bar input::placeholder {
    color: var(--text-hint);
}

/* ================================
   Tips Card
   ================================ */

.tips-card {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-md);
}

.tips-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.tips-header h3 {
    font-size: 16px;
    font-weight: 500;
    color: white;
}

.chat-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.25);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.chat-clear-btn:hover {
    background: rgba(255, 255, 255, 0.35);
}

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

#aiScreen .tips-header {
    justify-content: space-between;
    flex-wrap: wrap;
}

#aiScreen .tips-header h3 {
    flex: 1;
    min-width: 0;
}

.tips-list {
    list-style: none;
}

.tips-list li {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.95);
    padding-left: 20px;
    position: relative;
    margin-bottom: var(--spacing-sm);
    line-height: 1.5;
}

.tips-list li:last-child {
    margin-bottom: 0;
}

.tips-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    font-weight: 700;
    color: white;
}

/* ================================
   Checklist
   ================================ */

.checklist-group {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    min-height: 48px;
}

.checklist-item:active {
    background: var(--background);
}

.checklist-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-hint);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    position: relative;
}

.checklist-checkbox:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.checklist-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 6px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checklist-label {
    flex: 1;
    font-size: 15px;
    color: var(--text-primary);
    user-select: none;
}

.checklist-checkbox:checked + .checklist-label {
    color: var(--text-secondary);
    text-decoration: line-through;
}

.packing-add-row {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    align-items: center;
    border-top: 1px dashed rgba(0, 0, 0, 0.1);
    margin-top: var(--spacing-xs);
}

.packing-add-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #E0E0E0;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: 'Roboto', sans-serif;
    color: var(--text-primary);
    background: var(--surface);
}

.packing-add-input:focus {
    outline: none;
    border-color: var(--primary);
}

.packing-add-btn {
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    flex-shrink: 0;
}

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

.packing-remove-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--background);
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.packing-remove-btn:hover {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error);
}

.packing-remove-btn:active {
    transform: scale(0.95);
}

/* ================================
   Diary Entries
   ================================ */

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

.diary-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.diary-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
}

.diary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
}

.diary-destination {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

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

.diary-preview {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-md);
    text-align: center;
    min-height: 300px;
}

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

.empty-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.empty-message {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-lg);
    max-width: 280px;
    line-height: 1.5;
}

/* ================================
   Bottom Navigation
   ================================ */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: var(--bottom-nav-height);
    background: var(--surface);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 100;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    align-items: center;
}

.bottom-nav-tabs {
    display: contents;
}

.chat-input-container.chat-input-fixed {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--surface);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
    gap: var(--spacing-sm);
    margin-top: auto;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 100%;
    background: none;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%) scaleX(0);
    width: 60%;
    height: 3px;
    background: var(--primary);
    border-radius: 0 0 3px 3px;
    transition: transform var(--transition-base);
}

.nav-item.active::before {
    transform: translateX(-50%) scaleX(1);
}

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

.nav-item:active {
    background: var(--background);
}

.nav-icon {
    transition: all var(--transition-fast);
    width: 22px;
    height: 22px;
}

.nav-item.active .nav-icon {
    stroke: var(--primary);
    stroke-width: 2.5;
}

.nav-label {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* ================================
   Floating Action Button (FAB)
   ================================ */

.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 90;
}

.fab:hover {
    box-shadow: var(--shadow-xl);
}

.fab:active {
    transform: scale(0.95);
}

@media (min-width: 480px) {
    .fab {
        right: calc(50% - 240px + 16px);
    }
}

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

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 12px 24px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0.5px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    min-height: 48px;
    text-transform: uppercase;
    font-family: 'Roboto', sans-serif;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

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

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

.btn-secondary:active {
    background: #E8ECEF;
    transform: scale(0.98);
}

.btn-danger {
    background: var(--error);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
    background: #C0392B;
    box-shadow: var(--shadow-md);
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

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

.app-bar .icon-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

/* ================================
   Bottom Sheet
   ================================ */

.bottom-sheet {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 200;
    display: none;
}

.bottom-sheet.active {
    display: block;
}

.bottom-sheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn var(--transition-fast);
}

.bottom-sheet-content {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    background: var(--surface);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: slideUp var(--transition-base);
    display: flex;
    flex-direction: column;
}

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

.bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--background);
    flex-shrink: 0;
}

.bottom-sheet-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ================================
   Forms
   ================================ */

.trip-form {
    padding: var(--spacing-md);
    overflow-y: auto;
    flex: 1;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #E0E0E0;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-family: 'Roboto', sans-serif;
    color: var(--text-primary);
    background: var(--surface);
    transition: all var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

.form-actions {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    border-top: 1px solid var(--background);
    flex-shrink: 0;
}

.form-actions button {
    flex: 1;
}

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

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 300;
    display: none;
}

.modal.active {
    display: block;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn var(--transition-fast);
}

.modal-content {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: 100%;
    background: var(--surface);
    animation: slideInRight var(--transition-base);
    display: flex;
    flex-direction: column;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(-50%);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    background: var(--primary);
    color: white;
    flex-shrink: 0;
    min-height: var(--app-bar-height);
}

.modal-title {
    font-size: 20px;
    font-weight: 500;
    flex: 1;
    text-align: center;
}

.detail-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    background: var(--background);
}

.detail-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: var(--shadow-sm);
}

.detail-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--background);
}

.detail-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.detail-title {
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

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

.detail-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) 0;
}

.detail-row:not(:last-child) {
    border-bottom: 1px solid var(--background);
}

.detail-row-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--background);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
}

.detail-row-content {
    flex: 1;
}

.detail-row-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.detail-row-value {
    font-size: 15px;
    color: var(--text-primary);
    line-height: 1.5;
}

.modal-actions {
    padding: var(--spacing-md);
    border-top: 1px solid var(--background);
    flex-shrink: 0;
}

/* ================================
   Dialog
   ================================ */

.dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 400;
    display: none;
    align-items: center;
    justify-content: center;
}

.dialog.active {
    display: flex;
}

.dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn var(--transition-fast);
}

.dialog-content {
    position: relative;
    width: 90%;
    max-width: 360px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-xl);
    animation: scaleIn var(--transition-base);
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.dialog-title {
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
}

.dialog-message {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--spacing-lg);
}

.dialog-actions {
    display: flex;
    gap: var(--spacing-md);
}

.dialog-actions button {
    flex: 1;
}

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

.hidden {
    display: none !important;
}

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

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-sm); }
.mt-3 { margin-top: var(--spacing-md); }
.mt-4 { margin-top: var(--spacing-lg); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-sm); }
.mb-3 { margin-bottom: var(--spacing-md); }
.mb-4 { margin-bottom: var(--spacing-lg); }

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

@media (max-width: 360px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ================================
   Loading State
   ================================ */

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ================================
   Chat Interface (AI Assistant)
   ================================ */

.screen-chat {
    flex-direction: column;
    padding-bottom: 0;
}

.screen-chat.active {
    display: flex;
    min-height: calc(100vh - var(--app-bar-height) - var(--bottom-nav-height));
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-bottom: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    min-height: 0;
}

.chat-message {
    display: flex;
    gap: var(--spacing-sm);
    animation: slideInMessage var(--transition-base) forwards;
}

@keyframes slideInMessage {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-message.user .chat-avatar {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
}

.chat-message.ai .chat-avatar {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
}

.chat-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 15px;
    line-height: 1.5;
    position: relative;
}

.chat-message.user .chat-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message.ai .chat-bubble {
    background: var(--surface);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.chat-typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.chat-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typing 1.4s infinite;
}

.chat-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.chat-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #E0E0E0;
    border-radius: var(--radius-full);
    font-size: 15px;
    font-family: 'Roboto', sans-serif;
    color: var(--text-primary);
    background: var(--background);
    transition: all var(--transition-fast);
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--primary-dark);
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ================================
   Insights
   ================================ */

.insights-generate-btn {
    width: 100%;
    margin-bottom: var(--spacing-lg);
}

.insights-content {
    display: none;
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--spacing-lg);
}

.insights-loading,
.insights-error {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--text-secondary);
}

.insights-loading p,
.insights-error p {
    margin-top: var(--spacing-md);
    font-size: 14px;
}

.insights-result {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
}

.insights-result p {
    margin-bottom: var(--spacing-sm);
}

.insights-result p:last-child {
    margin-bottom: 0;
}

.insight-bullet {
    padding-left: var(--spacing-sm);
}

#insightsScreen .empty-state {
    margin-top: 0;
}

/* ================================
   Scrollbar Styling
   ================================ */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}
