/* ==========================================================================
   Base Styles & Variables
   ========================================================================== */
:root { 
    --bs-body-bg: #f4f6f9; 
    --card-bg: #ffffff; 
    --border-color: #e2e8f0;
    --primary-color: #003399; /* United Russia Blue */
    --primary-hover: #002266;
    --accent-color: #d52b1e; /* Flag Red */
    --accent-hover: #b9251a;
    --nav-bg: rgba(255, 255, 255, 0.95);
    --text-main: #1e293b;
    --text-muted: #64748b;
}

[data-bs-theme="dark"] { 
    --bs-body-bg: #0b1120; /* Deep Navy */
    --card-bg: #1e293b; 
    --border-color: #334155;
    --bs-secondary-bg: #1e293b;
    --nav-bg: rgba(30, 41, 59, 0.95);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }
.animate-slide-up { animation: slideUp 0.5s ease-out forwards; }

body { 
    font-family: 'Inter', system-ui, -apple-system, sans-serif; 
    background-color: var(--bs-body-bg);
    color: var(--text-main);
    padding-bottom: 90px; /* Space for mobile nav */
    transition: background-color 0.3s ease, color 0.3s ease; 
}

/* For the login page */
body.login-body {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 0;
}

/* ==========================================================================
   Components
   ========================================================================== */
   
/* Navbar (Top) */
.navbar { 
    background: var(--nav-bg); 
    backdrop-filter: blur(12px); 
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color); 
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.navbar-brand { color: var(--primary-color) !important; }

/* Cards */
.card { 
    border: 1px solid var(--border-color);
    border-radius: 16px; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03); 
    margin-bottom: 1.5rem; 
    background-color: var(--card-bg); 
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.3s ease, background-color 0.3s ease;
}

@media(min-width: 768px) {
    .card:hover { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025); }
}

.login-body .card {
    width: 100%;
    max-width: 400px;
    padding: 2rem !important;
}

[data-bs-theme="dark"] .card { box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2); }

/* Buttons */
.btn {
    border-radius: 10px;
    font-weight: 500;
    padding: 0.6rem 1.25rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary { background-color: var(--primary-color); border-color: var(--primary-color); }
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 51, 153, 0.3);
}

.btn-danger { background-color: var(--accent-color); border-color: var(--accent-color); }
.btn-danger:hover { background-color: var(--accent-hover); border-color: var(--accent-hover); box-shadow: 0 4px 12px rgba(213, 43, 30, 0.3); }

/* Floating Action Button (FAB) */
.fab-container {
    position: fixed;
    bottom: 90px; /* Above mobile nav */
    right: 20px;
    z-index: 1030;
}
.fab-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 6px 16px rgba(213, 43, 30, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-decoration: none;
}
.fab-btn:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 20px rgba(213, 43, 30, 0.5);
    color: white;
}

/* ==========================================================================
   Navigation Menu (Desktop vs Mobile)
   ========================================================================== */
.admin-menu-container {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.menu-link { 
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    padding: 10px; border-radius: 12px; font-weight: 600; font-size: 0.85rem;
    text-decoration: none; background: transparent; color: var(--text-muted); 
    transition: all 0.2s ease; flex: 1; min-width: 60px;
}
.menu-link i { font-size: 1.25rem; margin-bottom: 4px; transition: transform 0.2s; }
.menu-link:hover { color: var(--primary-color); }
.menu-link:hover i { transform: translateY(-2px); }
.menu-link.active { color: var(--primary-color); }

/* Bottom Nav for Mobile */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-color);
    padding: 8px 10px;
    z-index: 1020;
    box-shadow: 0 -4px 10px rgba(0,0,0,0.05);
}

@media (max-width: 767.98px) {
    .bottom-nav { display: flex; justify-content: space-around; }
    .desktop-only-menu { display: none !important; }
    .fab-container { bottom: 85px; right: 15px; }
}

@media (min-width: 768px) {
    body { padding-bottom: 0; }
    .admin-menu-container { flex-direction: row; justify-content: start; background: var(--card-bg); padding: 10px; border-radius: 16px; border: 1px solid var(--border-color); margin-bottom: 1.5rem; }
    .menu-link { flex-direction: row; font-size: 1rem; padding: 12px 24px; min-width: auto; }
    .menu-link i { margin-bottom: 0; margin-right: 8px; font-size: 1.1rem; }
    .menu-link.active { background: var(--primary-color); color: white; box-shadow: 0 4px 12px rgba(0, 51, 153, 0.3); }
    .menu-link:hover:not(.active) { background: rgba(0, 51, 153, 0.05); }
    .fab-container { display: none; } /* On desktop, use standard Add button */
}

/* ==========================================================================
   Tables & Mobile Cards
   ========================================================================== */
.table { margin-bottom: 0; }
.table th { font-weight: 600; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.05em; color: var(--text-muted); border-bottom-width: 1px; }

[data-bs-theme="dark"] .table { --bs-table-bg: transparent; color: var(--text-main); border-color: var(--border-color); }
[data-bs-theme="dark"] .table-light th { background-color: rgba(0,0,0,0.2); color: var(--text-muted); border-color: var(--border-color); }

.table-hover tbody tr { transition: background-color 0.2s ease; }
[data-bs-theme="dark"] .table-hover tbody tr:hover { background-color: rgba(255, 255, 255, 0.05); }

/* Mobile Table Cards Layout */
@media (max-width: 767.98px) {
    .d-mobile-none { display: none !important; }
    
    table#activistsTable, table#activistsTable tbody, table#activistsTable tr, table#activistsTable td {
        display: block; width: 100%;
    }
    table#activistsTable thead { display: none; }
    
    table#activistsTable tr {
        background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; margin-bottom: 12px; padding: 12px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    }
    
    table#activistsTable td {
        padding: 4px 0 !important; border: none; text-align: left;
    }
    
    /* Reorder for mobile card feel */
    table#activistsTable td:nth-child(2) { font-size: 1.1rem; border-bottom: 1px solid var(--border-color); padding-bottom: 8px !important; margin-bottom: 8px; }
    table#activistsTable td:nth-child(5) { font-weight: bold; color: var(--primary-color); }
    table#activistsTable td:last-child { display: none; } /* Hide right chevron cell if not needed */
}

/* Inputs & Form Controls */
.form-control, .form-select { padding: 0.8rem 1rem; border-radius: 10px; font-size: 1rem; border: 1px solid var(--border-color); background-color: var(--bs-body-bg); transition: all 0.2s ease; }
.form-control:focus, .form-select:focus { background-color: var(--card-bg); border-color: var(--primary-color); box-shadow: 0 0 0 0.25rem rgba(0, 51, 153, 0.15); }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select, [data-bs-theme="dark"] textarea { background-color: rgba(0,0,0,0.2); border-color: var(--border-color); color: #f1f5f9; }
[data-bs-theme="dark"] .form-control:focus, [data-bs-theme="dark"] .form-select:focus { background-color: var(--card-bg); }

/* ==========================================================================
   Utilities & Animations
   ========================================================================== */
@keyframes pulse-red { 
    0% { box-shadow: 0 0 0 0 rgba(213, 43, 30, 0.7); } 
    70% { box-shadow: 0 0 0 10px rgba(213, 43, 30, 0); } 
    100% { box-shadow: 0 0 0 0 rgba(213, 43, 30, 0); } 
}
.mic-active { width: 12px; height: 12px; background-color: var(--accent-color); border-radius: 50%; display: inline-block; animation: pulse-red 1.5s infinite; margin-right: 8px; }

/* DataTables Overrides for Mobile */
@media (max-width: 767.98px) {
    div.dataTables_wrapper div.row:first-child { display: flex !important; flex-direction: row !important; justify-content: space-between !important; align-items: center !important; margin-bottom: 15px !important; }
    div.dataTables_length { display: none; }
    div.dataTables_filter { text-align: left !important; margin: 0 !important; width: 100% !important; }
    div.dataTables_filter label { width: 100%; }
    div.dataTables_filter input { width: 100% !important; margin: 0 !important; border-radius: 12px; padding: 10px 15px; }
}
thead input { width: 100%; padding: 6px; font-size: 13px; border: 1px solid var(--border-color); border-radius: 6px; margin-top: 4px; background-color: var(--card-bg); color: inherit; }

.btn-circle {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
}

div.dataTables_length select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    padding: 0.375rem 2.25rem 0.375rem 0.75rem !important;
    font-size: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg) !important;
    color: var(--text-main);
    display: inline-block;
    width: auto !important;
    margin: 0 0.5rem;
}

[data-bs-theme="dark"] div.dataTables_length select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2394a3b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* SweetAlert2 Mobile Bottom Sheet */
@media (max-width: 767.98px) {
    .swal-bottom-sheet {
        align-items: flex-end !important;
        padding: 0 !important;
    }
    .swal-bottom-sheet .swal2-popup {
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 24px 24px 0 0 !important;
        animation: slideUp 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
        padding-bottom: env(safe-area-inset-bottom, 20px) !important;
    }
}
