/* Main CSS Stylesheet - Premium Mobile-First Design System */

:root {
    --primary: #2563EB;
    --primary-light: #EFF6FF;
    --success: #22C55E;
    --success-light: #F0FDF4;
    --danger: #EF4444;
    --danger-light: #FEF2F2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --background: #F8FAFC;
    --card: #FFFFFF;
    
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --border: #E2E8F0;
    
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.5;
    padding: 0;
    margin: 0;
    overflow-x: hidden;
}

/* --- COMMON UTILITIES & LAYOUT --- */
.d-flex { display: flex; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.flex-column { flex-direction: column; }
.flex-grow { flex-grow: 1; }
.flex-wrap { flex-wrap: wrap; }
.mt-2 { margin-top: 0.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.m-0 { margin: 0; }
.pt-3 { padding-top: 1rem; }
.border-top { border-top: 1px solid var(--border); }
.text-center { text-align: center; }
.text-danger { color: var(--danger) !important; }
.text-primary { color: var(--primary) !important; }
.cursor-pointer { cursor: pointer; }
.font-size-sm { font-size: 0.875rem; }
.highlight-green { color: var(--success); font-weight: 600; }

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* --- AUTH CONTAINER (Setup / Login) --- */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: radial-gradient(circle at top left, #EFF6FF 0%, #F8FAFC 70%);
}

.auth-card {
    background-color: var(--card);
    width: 100%;
    max-width: 400px;
    padding: 2.5rem 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

.auth-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* --- FORMS & INPUTS --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
select,
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary);
    background-color: var(--card);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    gap: 0.5rem;
}

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

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    background-color: var(--primary);
    color: #white;
    color: white;
}
.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-success {
    background-color: var(--success);
    color: white;
}
.btn-success:hover {
    background-color: #16a34a;
}

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

.btn-warning {
    background-color: var(--warning);
    color: white;
}
.btn-warning:hover {
    background-color: #d97706;
}

.btn-secondary {
    background-color: var(--border);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background-color: #cbd5e1;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.btn-xs {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
}

/* --- APP LAYOUT --- */
.app-container {
    max-width: 600px; /* Force mobile view on desktop */
    margin: 0 auto;
    background-color: var(--background);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.03);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
}

.app-header {
    background-color: var(--card);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    font-size: 1.5rem;
    background-color: var(--primary-light);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.user-text {
    display: flex;
    flex-direction: column;
}

.greeting {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.username {
    font-size: 0.95rem;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon-header {
    background: none;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.btn-icon-header:hover {
    background-color: var(--background);
}

.app-main {
    flex-grow: 1;
    padding: 1.25rem;
    padding-bottom: 90px; /* Space for bottom nav */
}

/* --- TAB ROUTING --- */
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: fadeIn 0.25s ease-out;
}

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

/* --- BOTTOM NAVIGATION BAR --- */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    height: 70px;
    background-color: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.02);
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 20%;
    height: 100%;
    font-size: 0.7rem;
    font-weight: 500;
    transition: all 0.2s ease;
    outline: none;
}

.nav-btn svg {
    transition: transform 0.2s ease;
}

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

.nav-btn.active svg {
    color: var(--primary);
    transform: translateY(-2px);
}

.nav-btn span {
    font-family: inherit;
}

/* --- CARDS & WIDGETS --- */
.card {
    background-color: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.section-title-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.section-title-bar h2 {
    font-size: 1.35rem;
    font-weight: 700;
}

/* --- FINANCIAL TOTAL CARD --- */
.assets-card {
    background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-lg);
}

.assets-header {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.assets-value {
    font-size: 2rem;
    font-weight: 800;
    margin: 0.25rem 0 1rem 0;
}

.assets-breakdown {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 0.75rem;
}

.breakdown-item {
    display: flex;
    flex-direction: column;
    width: 48%;
}

.breakdown-label {
    font-size: 0.75rem;
    opacity: 0.7;
}

.breakdown-val {
    font-size: 1rem;
    font-weight: 600;
}

/* --- SAVING GOAL PROGRESS CARD --- */
.goal-card .goal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.goal-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.goal-badge {
    font-size: 0.75rem;
    background-color: var(--primary-light);
    color: var(--primary);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
}

.goal-metrics {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.goal-metrics .metric {
    display: flex;
    flex-direction: column;
}

.goal-metrics .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.goal-metrics .val {
    font-size: 1rem;
    font-weight: 700;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--background);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.goal-footer {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* --- FAST ACTIONS PANEL --- */
.fast-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.fast-actions .btn {
    flex: 1;
    padding: 0.85rem;
}

/* --- BULK INPUT WIDGET --- */
.bulk-input-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

#bulk-textarea {
    min-height: 110px;
    resize: vertical;
    font-family: monospace;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.bulk-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.bulk-preview-area {
    margin-top: 1.25rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.bulk-preview-area h4 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.preview-table th,
.preview-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.preview-table th {
    font-weight: 600;
    color: var(--text-secondary);
}

.preview-table input,
.preview-table select {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.preview-row-delete {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* --- DASHBOARD WIDGETS --- */
.dashboard-widget h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 220px;
}

/* --- RECENT ITEMS LISTS --- */
.recent-card .recent-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.recent-card h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.recent-card a {
    font-size: 0.8rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px dotted var(--border);
}

.item-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.item-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.item-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.item-icon.expense {
    background-color: var(--danger-light);
}

.item-icon.investment {
    background-color: var(--primary-light);
}

.item-details {
    display: flex;
    flex-direction: column;
}

.item-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.item-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.item-right {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.item-value {
    font-size: 0.95rem;
    font-weight: 700;
}

.item-value.expense {
    color: var(--danger);
}

.item-value.investment {
    color: var(--primary);
}

/* --- FILTER CARD TRANSACTIONS --- */
.filter-card {
    padding: 1rem;
}

.filter-row {
    display: flex;
    gap: 0.5rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    width: 50%;
}

.filter-group.flex-grow {
    width: 70%;
}

.filter-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.filter-group input,
.filter-group select {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
}

.transactions-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* --- PREMIUM LIST ITEM FOR TRANSACTION PANEL --- */
.tx-list-item {
    background-color: var(--card);
    border-radius: var(--radius-md);
    padding: 0.85rem 1rem;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.tx-list-actions {
    display: flex;
    gap: 0.35rem;
    align-self: center;
    margin-left: 0.5rem;
}

.btn-action {
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background-color 0.2s ease;
}

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

.btn-action.delete:hover {
    background-color: var(--danger-light);
    color: var(--danger);
}

/* --- INVESTMENT PORTFOLIO PANEL --- */
.investment-summary-card {
    background: linear-gradient(135deg, var(--success) 0%, #15803d 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.investment-summary-card .summary-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.investment-summary-card .summary-value {
    font-size: 1.85rem;
    font-weight: 800;
    margin: 0.25rem 0;
}

.investment-summary-card .summary-subtitle {
    font-size: 0.75rem;
    opacity: 0.85;
}

.investments-list-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.inv-list-item {
    background-color: var(--card);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.inv-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.inv-name-tag {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inv-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-weight: 600;
}

.inv-badge.vps { background-color: #E0F2FE; color: #0369A1; }
.inv-badge.account { background-color: #D1FAE5; color: #065F46; }
.inv-badge.proxy { background-color: #F3E8FF; color: #7E22CE; }
.inv-badge.domain { background-color: #FEF3C7; color: #D97706; }
.inv-badge.tool { background-color: #FCE7F3; color: #9D174D; }
.inv-badge.other { background-color: #F1F5F9; color: #475569; }

.inv-notes {
    font-size: 0.8rem;
    color: var(--text-secondary);
    border-top: 1px dotted var(--border);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}

/* --- REPORTS RANGE SELECTOR --- */
.range-selector {
    display: flex;
    background-color: var(--border);
    border-radius: var(--radius-md);
    padding: 3px;
    margin-bottom: 1.25rem;
}

.range-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.range-btn.active {
    background-color: var(--card);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.reports-grid {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.report-box {
    flex: 1;
    padding: 1rem;
    text-align: center;
    margin-bottom: 0;
}

.box-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.box-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.report-widget h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* --- SETTINGS GROUPS --- */
.settings-group h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.data-actions-vertical {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.data-action-row {
    display: flex;
    width: 100%;
}

.backup-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.backup-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background-color: var(--background);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    border: 1px solid var(--border);
}

.backup-meta-text {
    display: flex;
    flex-direction: column;
}

.backup-title-span {
    font-weight: 600;
}

.backup-date-span {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.backup-item-actions {
    display: flex;
    gap: 0.25rem;
}

/* --- MODALS GENERAL --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: flex-end; /* Slide from bottom for mobile */
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

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

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
}

.modal-container {
    background-color: var(--card);
    width: 100%;
    max-width: 500px;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    z-index: 1001;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.94, 0.6, 1);
}

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

@media(min-width: 600px) {
    .modal {
        align-items: center;
    }
    .modal-container {
        border-radius: var(--radius-lg);
        transform: scale(0.95);
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }
    .modal.active .modal-container {
        transform: scale(1);
    }
}

.modal-sm {
    max-width: 400px;
}

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

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    margin-bottom: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    margin-top: 1.25rem;
}

/* Toggle Group Buttons in Add Modal */
.toggle-group-type {
    display: flex;
    background-color: var(--background);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.toggle-group-type input[type="radio"] {
    display: none;
}

.toggle-label {
    flex: 1;
    text-align: center;
    padding: 0.6rem 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.toggle-group-type input[type="radio"]:checked + .toggle-label {
    background-color: var(--card);
    box-shadow: var(--shadow-sm);
}

.toggle-group-type input[type="radio"]#tx-type-expense:checked + .toggle-label {
    color: var(--danger);
}

.toggle-group-type input[type="radio"]#tx-type-investment:checked + .toggle-label {
    color: var(--primary);
}


/* --- SLIDE-IN CHAT ADVISOR DRAWER --- */
.chat-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.chat-drawer.active {
    opacity: 1;
    pointer-events: auto;
}

.chat-drawer-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.chat-drawer-container {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 85%;
    max-width: 420px;
    background-color: var(--background);
    z-index: 901;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.94, 0.6, 1);
    display: flex;
    flex-direction: column;
}

.chat-drawer.active .chat-drawer-container {
    transform: translateX(0);
}

.chat-drawer-header {
    background-color: #1e3a8a;
    color: white;
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-avatar {
    font-size: 1.75rem;
    margin-right: 0.75rem;
}

.chat-status {
    font-size: 0.65rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: #22C55E;
    border-radius: 50%;
    display: inline-block;
}

.chat-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: white;
    cursor: pointer;
    opacity: 0.8;
}

.chat-close:hover {
    opacity: 1;
}

.chat-messages {
    flex-grow: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-bubble {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 1.15rem;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-line;
}

.chat-bubble.ai {
    background-color: var(--card);
    color: var(--text-primary);
    align-self: flex-start;
    border-top-left-radius: 0.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.chat-bubble.user {
    background-color: var(--primary);
    color: white;
    align-self: flex-end;
    border-top-right-radius: 0.25rem;
}

.chat-bubble.loading {
    align-self: flex-start;
    background-color: var(--card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-input-area {
    padding: 0.75rem 1rem;
    background-color: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

.chat-input-area input {
    flex-grow: 1;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
}

.chat-send-btn {
    background-color: var(--primary);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chat-send-btn:hover {
    background-color: #1d4ed8;
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    width: 90%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background-color: var(--card);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 600;
    animation: slideDown 0.3s ease-out forwards;
}

.toast.success { border-left-color: var(--success); }
.toast.danger { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

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

.toast-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-secondary);
    margin-left: 0.75rem;
    line-height: 1;
}

/* --- GLOBAL LOADING SCREEN OVERLAY --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid var(--border);
    border-top: 5px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
