/* base.css - Variables, keyframes, global enhancements, toasts, search, tables, footer, responsive */

/* Shake animation for login errors */
@keyframes shakeX {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

:root {
    --bs-font-sans-serif: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --bs-body-font-family: var(--bs-font-sans-serif);
    --eff-primary: #198754;
    --eff-primary-dark: #157347;
    --eff-primary-light: #d1e7dd;
    --eff-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --eff-shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
    --eff-transition: all 0.3s ease;
    /* Sidebar variables */
    --sidebar-width-expanded: 260px;
    --sidebar-width-collapsed: 72px;
    --sidebar-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --header-height: 60px;
}

* {
    font-family: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: #f8f9fa;
}

/* ==================== GLOBAL ENHANCEMENTS ==================== */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.hover-lift {
    transition: var(--eff-transition);
}

.hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: var(--eff-shadow-hover);
}

/* Toast Notification System */
.toast-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
}

.toast-notification {
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.12);
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 220px;
    max-width: 380px;
    font-size: 0.8rem;
    animation: slideInRight 0.3s ease-out;
    border-left: 3px solid var(--eff-primary);
    background: #f0f9ff;
    color: #1e293b;
}

.toast-notification > span:first-of-type {
    flex: 1;
    min-width: 0;
}

.toast-notification.toast-success { border-left-color: #198754; background: #f0fdf4; }
.toast-notification.toast-error { border-left-color: #dc3545; background: #fef2f2; }
.toast-notification.toast-warning { border-left-color: #ffc107; background: #fffbeb; }
.toast-notification.toast-info { border-left-color: #0dcaf0; background: #f0f9ff; }

.toast-notification .toast-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.toast-notification.toast-success .toast-icon { color: #198754; }
.toast-notification.toast-error .toast-icon { color: #dc3545; }
.toast-notification.toast-warning .toast-icon { color: #ffc107; }
.toast-notification.toast-info .toast-icon { color: #0dcaf0; }


@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

/* Modal Enhancements */
.modal-confirm {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 9998;
    align-items: center;
    justify-content: center;
}

.modal-confirm.show {
    display: flex;
}

.modal-confirm-content {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    text-align: center;
    animation: fadeIn 0.2s ease-out;
}

.modal-confirm-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.5rem;
}

.modal-confirm-icon.success { background: #d1e7dd; color: #198754; }
.modal-confirm-icon.warning { background: #fff3cd; color: #664d03; }
.modal-confirm-icon.danger { background: #f8d7da; color: #dc3545; }

/* Notification Dropdown */
.notification-dropdown {
    position: relative;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

.notification-menu {
    position: absolute;
    top: 100%;
    right: 0;
    width: 320px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    display: none;
    z-index: 1000;
    overflow: hidden;
}

.notification-menu.show {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

.notification-header {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item:hover {
    background: #f8f9fa;
}

.notification-item.unread {
    background: #f0fff4;
}

.notification-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.notification-item-icon.success { background: #d1e7dd; color: #198754; }
.notification-item-icon.info { background: #cfe2ff; color: #084298; }
.notification-item-icon.warning { background: #fff3cd; color: #664d03; }

.notification-footer {
    padding: 0.75rem;
    text-align: center;
    border-top: 1px solid #dee2e6;
}

/* Search Box Enhancement */
.search-box {
    position: relative;
}

.search-box input {
    padding-left: 2.5rem;
    border-radius: 20px;
    border: 1px solid #dee2e6;
    transition: var(--eff-transition);
}

.search-box input:focus {
    border-color: var(--eff-primary);
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.1);
}

.search-box .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

/* Global Search Results */
.global-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1050;
    max-height: 400px;
    overflow-y: auto;
    margin-top: 4px;
}

.search-result-section {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.search-result-section:last-child {
    border-bottom: none;
}

.search-result-section-title {
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item .result-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.search-result-item .result-icon.claim { background: #d1e7dd; color: #198754; }
.search-result-item .result-icon.deceased { background: #cfe2ff; color: #0d6efd; }

.search-result-item .result-info {
    flex: 1;
    min-width: 0;
}

.search-result-item .result-title {
    font-weight: 500;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-item .result-subtitle {
    font-size: 12px;
    color: #6c757d;
}

.search-no-results {
    padding: 20px;
    text-align: center;
    color: #6c757d;
}

/* ==================== TABLE STYLES ==================== */
.table-container {
    background: #fff;
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--eff-shadow);
}

.table-header {
    background: #fff;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-header h5 {
    margin: 0;
    font-weight: 600;
    color: #212529;
}

.table {
    margin: 0;
}

.table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    padding: 0.875rem 1rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table td {
    padding: 0.875rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f0f0f0;
}

.table tbody tr {
    transition: background 0.2s;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.status-badge {
    padding: 0.4rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-approved { background-color: #d1e7dd; color: #0f5132; }
.status-pending { background-color: #fff3cd; color: #664d03; }
.status-processing { background-color: #cfe2ff; color: #084298; }
.status-denied { background-color: #f8d7da; color: #842029; }
.status-funded { background-color: #d1e7dd; color: #0f5132; }

/* Action buttons in tables */
.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-actions .btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #6c757d;
    transition: var(--eff-transition);
}

.table-actions .btn-icon:hover {
    border-color: var(--eff-primary);
    color: var(--eff-primary);
    background: #f0fff4;
}

.table-actions .btn-icon.danger:hover {
    border-color: #dc3545;
    color: #dc3545;
    background: #fff5f5;
}

/* ==================== FOOTER STYLES ==================== */
.main-footer {
    background-color: #fff;
    border-top: 1px solid #dee2e6;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width-expanded);
    right: 0;
    z-index: 100;
    transition: var(--sidebar-transition);
}

.sidebar-collapsed .main-footer {
    left: var(--sidebar-width-collapsed);
}

.footer-logo {
    height: 32px;
}

.footer-brand {
    font-weight: 600;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .welcome-banner {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    .quick-actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 992px) {
    .page-section.flex-section.active {
        flex-direction: column;
    }
    .step-nav {
        width: 100%;
        display: flex;
        overflow-x: auto;
        padding: 1.25rem 1.5rem;
        border-bottom: 1px solid #dee2e6;
        position: static;
        max-height: none;
        left: auto;
        top: auto;
        bottom: auto;
        border-right: none;
    }
    .step-item {
        padding-bottom: 0;
        padding-right: 2rem;
        flex-shrink: 0;
    }
    .step-item::before {
        display: none;
    }
    .form-area {
        padding: 2rem;
    }
    #page-create-claim .form-area {
        margin-left: 0;
    }
    .form-content {
        max-width: 100%;
    }
    .stats-card-content {
        flex-direction: column;
        text-align: center;
    }
    .stats-card-info {
        text-align: center;
    }
}

@media (max-width: 768px) {
    .dashboard-content {
        padding: 1rem;
    }
    .welcome-banner {
        padding: 1rem 1.25rem;
    }
    .quick-actions {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }
    .quick-action-btn {
        justify-content: center;
        padding: 0.65rem 0.75rem;
        font-size: 0.9rem;
    }
    .stats-card {
        padding: 1rem;
    }
    .stats-card h3 {
        font-size: 1.5rem;
    }
    .table-container {
        margin-bottom: 1rem;
    }
    .main-header {
        padding: 0.5rem;
    }
    .notification-menu {
        position: fixed;
        right: 10px;
        left: 10px;
        width: auto;
    }
    .toast-container {
        left: 10px;
        right: 10px;
    }
    .toast-notification {
        min-width: auto;
    }
}

@media (max-width: 576px) {
    .quick-actions {
        grid-template-columns: 1fr;
    }
    .main-footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    .main-footer > div {
        justify-content: center !important;
    }
}

.app-container {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.app-container.active {
    display: flex;
}

.step-panel {
    display: none;
}

.step-panel.active {
    display: block;
}

/* ==================== LOADING OVERLAY ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #0a1a0f 0%, #0d2818 50%, #0a1a0f 100%);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.loading-overlay.active {
    display: flex;
    opacity: 1;
}

.loading-overlay.fade-out {
    opacity: 0;
    transition: opacity 0.6s ease-out;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

/* Logo wrapper — positions glow, ring, and avatar */
.loading-logo-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pulsing glow behind the avatar */
.loading-glow {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(34, 197, 94, 0.35) 0%, rgba(25, 135, 84, 0.15) 50%, transparent 70%);
    animation: loadingGlow 3s ease-in-out infinite;
}

@keyframes loadingGlow {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.4); opacity: 0.8; }
}

/* Spinning ring around the avatar */
.loading-ring {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    border: 2px solid transparent;
    border-top: 2px solid #22c55e;
    border-right: 2px solid rgba(34, 197, 94, 0.3);
    animation: loadingRingSpin 1.8s linear infinite;
}

@keyframes loadingRingSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Second ring — counter-rotating, slower */
.loading-ring::after {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 1px solid transparent;
    border-bottom: 1px solid rgba(34, 197, 94, 0.2);
    border-left: 1px solid rgba(34, 197, 94, 0.1);
    animation: loadingRingSpin 3s linear infinite reverse;
}

/* The EFF avatar circle */
.loading-avatar {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: linear-gradient(135deg, #198754 0%, #157347 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.05);
    animation: loadingPulse 2.5s ease-in-out infinite;
    z-index: 1;
}

.loading-avatar span {
    color: #fff;
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 1.5px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

@keyframes loadingPulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 30px rgba(34, 197, 94, 0.3), inset 0 0 20px rgba(255, 255, 255, 0.05); }
    50% { transform: scale(1.06); box-shadow: 0 0 50px rgba(34, 197, 94, 0.5), inset 0 0 20px rgba(255, 255, 255, 0.08); }
}

/* Status text with animated dots */
.loading-status {
    color: rgba(255, 255, 255, 0.85);
    font-family: 'Jost', sans-serif;
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    margin: 0;
    min-width: 200px;
    text-align: center;
}

.loading-status::after {
    content: '';
    animation: loadingDots 1.5s steps(4, end) infinite;
}

@keyframes loadingDots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* Blur the app behind the overlay */
.app-container.loading-blur {
    filter: blur(6px);
    transition: filter 0.3s ease;
}

.app-container.loading-blur-clear {
    filter: none;
    transition: filter 0.6s ease;
}
