/* Global Typography & CSS Variable Tokens */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #080710;
    --bg-surface: rgba(255, 255, 255, 0.04);
    --bg-surface-hover: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(147, 51, 234, 0.4);
    
    --color-text-primary: #f3f4f6;
    --color-text-secondary: #9ca3af;
    --color-text-muted: #6b7280;

    --brand-primary: #8b5cf6;
    --brand-primary-glow: rgba(139, 92, 246, 0.3);
    --brand-secondary: #ec4899;

    --status-healthy: #10b981;
    --status-healthy-glow: rgba(16, 185, 129, 0.2);
    --status-failing: #f59e0b;
    --status-failing-glow: rgba(245, 158, 11, 0.2);
    --status-suspended: #ef4444;
    --status-suspended-glow: rgba(239, 68, 68, 0.2);
    --status-pending: #3b82f6;
    --status-pending-glow: rgba(59, 130, 246, 0.2);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 8px;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Scaffold Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Modern Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(8, 7, 16, 0.5);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--brand-primary);
}

/* Dropdown Option Color Fix (Prevents white-on-white text in browsers) */
select option {
    background-color: #0f0c1e;
    color: var(--color-text-primary);
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(at 10% 20%, rgba(139, 92, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 80%, rgba(236, 72, 153, 0.1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--color-text-primary);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

/* Navbar / App Header */
.navbar {
    background: rgba(8, 7, 16, 0.7);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, var(--color-text-primary) 30%, var(--brand-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    font-weight: 500;
    color: var(--color-text-secondary);
    transition: var(--transition-smooth);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
}

.nav-link:hover, .nav-link.active {
    color: var(--color-text-primary);
    background: var(--bg-surface);
}

.logout-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
}

/* Auth Pages Layout */
.auth-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.auth-card {
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 440px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: var(--transition-smooth);
}

.auth-card:hover {
    border-color: rgba(139, 92, 246, 0.2);
    box-shadow: 0 25px 50px -12px rgba(139, 92, 246, 0.1);
}

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

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

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

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

.form-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.form-control:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-glow);
    background: rgba(255, 255, 255, 0.06);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    background: linear-gradient(135deg, var(--brand-primary), #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.8rem 1.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px var(--brand-primary-glow);
    opacity: 0.95;
}

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--color-text-primary);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    box-shadow: none;
}

.btn-danger {
    background: var(--status-suspended);
}

.btn-danger:hover {
    box-shadow: 0 4px 20px var(--status-suspended-glow);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    color: var(--color-text-secondary);
}

.auth-link {
    color: var(--brand-primary);
    font-weight: 500;
}

.auth-link:hover {
    text-decoration: underline;
}

/* Dashboard Layout */
.dashboard-wrapper {
    flex: 1;
    padding: 2.5rem 2rem;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

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

.dashboard-title h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.dashboard-title p {
    color: var(--color-text-secondary);
}

/* Grid & Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.metric-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.metric-header i {
    font-size: 1.25rem;
    color: var(--brand-primary);
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

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

/* Table styling */
.table-card {
    overflow: hidden;
    padding: 0;
}

.table-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.table-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.responsive-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.responsive-table th, .responsive-table td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.responsive-table th {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--color-text-secondary);
    font-weight: 600;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.01);
}

.responsive-table tr:last-child td {
    border-bottom: none;
}

.responsive-table tr:hover td {
    background: rgba(255, 255, 255, 0.01);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-healthy, .badge-active, .badge-sent {
    background: var(--status-healthy-glow);
    color: var(--status-healthy);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-failing, .badge-suspended {
    background: var(--status-failing-glow);
    color: var(--status-failing);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-failed {
    background: var(--status-suspended-glow);
    color: var(--status-suspended);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-pending, .badge-pending_approval {
    background: var(--status-pending-glow);
    color: var(--status-pending);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Modals & Overlays */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}

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

.modal-content {
    background: rgba(15, 12, 30, 0.95);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2.25rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    transform: scale(0.95);
    transition: var(--transition-smooth);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* Console modal override – internal panels manage their own scroll */
#console-main-modal .modal-content {
    overflow: hidden;
}

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

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

.modal-close {
    background: none;
    border: none;
    color: var(--color-text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.modal-close:hover {
    color: var(--color-text-primary);
}

/* Alert Notification Banner */
.alert {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.9rem;
}

.alert-success {
    background: var(--status-healthy-glow);
    border-color: rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
}

.alert-error {
    background: var(--status-suspended-glow);
    border-color: rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Secure API Box */
.secure-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px dashed var(--brand-primary);
    border-radius: var(--radius-sm);
    padding: 1rem;
    font-family: monospace;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #e9d5ff;
    margin: 1rem 0;
    gap: 1rem;
    word-break: break-all;
}

.copy-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--color-text-primary);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    transition: var(--transition-smooth);
}

.copy-btn:hover {
    background: var(--brand-primary);
    color: white;
}

/* Pagination */
.pagination-wrapper {
    padding: 1.5rem;
    display: flex;
    justify-content: center;
}

.pagination-wrapper nav {
    display: flex;
    gap: 0.25rem;
}

.pagination-wrapper svg {
    width: 1.25rem;
    height: 1.25rem;
}

.pagination-wrapper span, .pagination-wrapper a {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
}

.pagination-wrapper a:hover {
    background: var(--bg-surface-hover);
}

/* Grid for columns */
.row {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.col-6 {
    flex: 1;
    min-width: 300px;
}

/* Actions Menu */
.actions-cell {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--color-text-primary);
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-icon:hover {
    background: var(--bg-surface-hover);
    border-color: var(--color-text-secondary);
}

.btn-icon-danger:hover {
    background: var(--status-suspended-glow);
    border-color: var(--status-suspended);
    color: #fca5a5;
}

/* Sidenav & Mobile menu default overrides for desktop */
.mobile-menu-toggle {
    display: none;
}
.mobile-sidenav {
    display: none;
}
.mobile-sidenav-overlay {
    display: none;
}

/* Responsive / Mobile Layout Adjustments */
@media (max-width: 768px) {
    /* Navbar styles on mobile with hamburger */
    .navbar {
        padding: 1rem 1.5rem;
        position: sticky;
        top: 0;
    }

    .navbar-brand {
        font-size: 1.30rem;
    }

    .navbar-links {
        display: none !important; /* Hide desktop links on mobile */
    }

    /* Show hamburger menu toggle button on mobile */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--color-text-primary);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        transition: var(--transition-smooth);
    }
    .mobile-menu-toggle:hover {
        color: var(--brand-primary);
    }

    /* Mobile Sidenav Overlay style */
    .mobile-sidenav-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }
    .mobile-sidenav-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Mobile Sidenav Drawer style */
    .mobile-sidenav {
        display: flex;
        position: fixed;
        top: 0;
        right: -280px;
        width: 280px;
        height: 100vh;
        background: rgba(11, 10, 19, 0.96);
        backdrop-filter: blur(25px);
        border-left: 1px solid var(--border-color);
        z-index: 1001;
        flex-direction: column;
        padding: 1.5rem;
        transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .mobile-sidenav.active {
        right: 0;
    }

    .mobile-sidenav-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 2rem;
    }

    .mobile-sidenav-close {
        background: none;
        border: none;
        color: var(--color-text-secondary);
        font-size: 1.5rem;
        cursor: pointer;
        transition: var(--transition-smooth);
    }
    .mobile-sidenav-close:hover {
        color: var(--brand-primary);
    }

    .mobile-sidenav-links {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        flex-grow: 1;
    }

    .mobile-sidenav-links .nav-link {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        font-weight: 500;
        color: var(--color-text-secondary);
        padding: 0.75rem 1rem;
        border-radius: var(--radius-sm);
        transition: var(--transition-smooth);
        border: 1px solid transparent;
        font-size: 0.95rem;
    }

    .mobile-sidenav-links .nav-link:hover,
    .mobile-sidenav-links .nav-link.active {
        background: rgba(139, 92, 246, 0.15);
        color: #d8b4fe;
        border-color: rgba(139, 92, 246, 0.25);
    }

    /* Grid layout auto-stacking */
    .metrics-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Modal optimization on tiny viewports */
    .modal-content {
        width: 94%;
        padding: 1.25rem;
        margin: 10px;
    }
    
    .row {
        flex-direction: column !important;
        gap: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .col-6 {
        width: 100% !important;
        min-width: 100% !important;
    }

    /* Dashboard & Wrapper Responsive Spacing */
    .dashboard-wrapper {
        padding: 1.5rem 1rem !important;
    }

    .dashboard-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1.25rem !important;
        margin-bottom: 1.75rem !important;
    }

    .dashboard-header .btn {
        width: 100% !important;
    }

    /* Table Responsiveness & Card Scroll */
    .table-card {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .responsive-table {
        min-width: 700px; /* Forces horizontal scrolling on narrow screens instead of breaking layouts */
    }

    .table-header-row {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem !important;
        padding: 1.25rem 1rem !important;
    }

    .table-header-row .btn, .table-header-row select {
        width: 100% !important;
    }

    /* Auth views padding optimization */
    .auth-container {
        padding: 1rem !important;
    }

    .auth-card {
        padding: 1.75rem 1.25rem !important;
    }

    /* OTP Code digit inputs responsiveness */
    .otp-digit-input {
        width: 2.35rem !important;
        height: 2.35rem !important;
        font-size: 1.25rem !important;
    }
    .otp-inputs-wrapper {
        gap: 0.35rem !important;
    }
}
