/* ========================================
   SelfAttest AI - Teaser Reality Design System
   Theme: Dark Glassmorphism, Neon Accents, Futuristic Typography
   ======================================== */

:root {
    /* Color Palette - Deep Space & Neon */
    --bg-dark: #020617;
    /* Slate 950 - Main Background */
    --bg-card: rgba(15, 23, 42, 0.6);
    /* Slate 900 with opacity */
    --bg-glass: rgba(30, 41, 59, 0.4);
    /* Slate 800 with opacity */

    --primary: #3b82f6;
    /* Blue 500 - Primary Action */
    --primary-glow: rgba(59, 130, 246, 0.5);
    --accent: #8b5cf6;
    /* Violet 500 - Secondary/AI */
    --accent-glow: rgba(139, 92, 246, 0.5);

    --success: #10b981;
    /* Emerald 500 */
    --success-glow: rgba(16, 185, 129, 0.5);
    --warning: #f59e0b;
    /* Amber 500 */
    --danger: #ef4444;
    /* Red 500 */

    --text-primary: #f8fafc;
    /* Slate 50 */
    --text-secondary: #cbd5e1;
    /* Slate 300 */
    --text-muted: #64748b;
    /* Slate 500 */

    --border-light: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);

    /* Spacing & Layout */
    --header-height: 70px;
    --sidebar-width: 260px;
    --radius-lg: 24px;
    /* Squircle-like */
    --radius-md: 16px;
    --radius-sm: 8px;

    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Typography */
    --font-heading: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* ========================================
   Global Reset & Base Styles
   ======================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.15) 0%, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.02em;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--accent);
    text-shadow: 0 0 8px var(--accent-glow);
}

/* ========================================
   Layout Structure
   ======================================== */

.admin-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "header header"
        "nav main";
    min-height: 100vh;
}

/* Header */
.admin-header {
    grid-area: header;
    background: rgba(2, 6, 23, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-xl);
    position: sticky;
    color: var(--text-muted);
    margin-top: -4px;
}

/* Sidebar Navigation */
.admin-nav {
    grid-area: nav;
    background: rgba(15, 23, 42, 0.3);
    border-right: 1px solid var(--border-light);
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    height: 100%;
    position: relative;
    overflow-y: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    text-align: left;
    width: 100%;
    font-family: var(--font-body);
    font-size: 0.95rem;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-link.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, transparent 100%);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: var(--primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.1);
}

.nav-icon {
    font-size: 1.2rem;
}

/* Main Content */
.admin-main {
    grid-area: main;
    padding: 0;
    overflow-y: auto;
    height: 100%;
}

#page-dashboard,
#page-changelog,
#page-training,
#page-quiz,
#page-schedule,
#page-simulator,
#page-analytics {
    padding: var(--space-xl);
}

/* ========================================
   Components
   ======================================== */

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-md);
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-control {
    width: 100%;
    padding: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

/* Accordion */
.accordion {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.accordion-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.accordion-header {
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: background 0.2s;
}

.accordion-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.accordion-body {
    padding: 0 16px;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease-out;
    background: rgba(0, 0, 0, 0.2);
}

.accordion-item.expanded .accordion-body {
    padding: 16px;
    max-height: 500px;
    /* Arbitrary large height */
    border-top: 1px solid var(--border-light);
}

.expand-icon {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.accordion-item.expanded .expand-icon {
    transform: rotate(180deg);
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-critical {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-high {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-medium {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-low {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar-container {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Empty State */
.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-2xl);
    font-style: italic;
    font-size: 0.9rem;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--text-muted);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Tabs */
.tabs-header {
    display: flex;
    gap: 10px;
}

.tab-btn {
    padding: 10px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-family: var(--font-body);
    min-height: 44px;
}


/* Hide Profile/Avatar Section */
.user-profile,
.avatar-container,
.profile-section {
    display: none !important;
}


/* ========================================
   Dashboard Grids (Restored)
   ======================================== */

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-lg);
}

/* Status Grid */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.status-item {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    transition: transform 0.2s, box-shadow 0.2s;
}

.status-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: var(--primary);
}

.status-icon {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.status-content {
    display: flex;
    flex-direction: column;
}

.status-content .label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-content .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.status-ready {
    color: var(--success);
}

/* Simulator Iframe */
.simulator-frame {
    width: 100%;
    height: calc(100vh - 220px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    background: #0a0a0a;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    /* Default to no zoom for better compatibility */
    transform: none;
    transform-origin: top left;
}

/* Container to handle scroll if zoomed */
#page-simulator .card {
    overflow: hidden;
}

/* ========================================
   Notification Animations
   ======================================== */

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* ========================================
   Profile & Logout Styles (Added)
   ======================================== */
.profile-section {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-left: 20px;
    border-left: 1px solid var(--border-light);
    padding-left: 20px;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--primary);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.profile-details {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.profile-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.profile-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
}


/* ========================================
   Schedule Manager & Cron Monitor Styles
   ======================================== */

.schedule-manager {
    max-width: 100%;
}

.schedule-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
}

.schedule-icon {
    font-size: 3rem;
    opacity: 0.8;
}

.schedule-info {
    flex: 1;
}

.schedule-title {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.schedule-description {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.schedule-cron {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.schedule-cron code {
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--primary);
}

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

.schedule-editor {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.schedule-editor h3 {
    margin-bottom: 20px;
}

/* Cron Monitor Styles */
.cron-monitor {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-light);
}

.monitor-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.monitor-status-badge {
    display: flex;
    align-items: center;
}

.cron-status {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.cron-status-idle {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-muted);
}

.cron-status-running {
    background: rgba(59, 130, 246, 0.2);
    color: var(--primary);
    animation: pulse 2s infinite;
}

.cron-status-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.cron-status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.monitor-body {
    padding: 24px;
}

.monitor-message {
    margin-bottom: 24px;
}

.status-message {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}


.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    animation: progress 2s infinite;
}

@keyframes progress {
    0% {
        width: 0%;
    }

    50% {
        width: 70%;
    }

    100% {
        width: 100%;
    }
}

.monitor-logs {
    margin-bottom: 24px;
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.logs-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

.log-entry {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    gap: 12px;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: var(--text-muted);
    min-width: 80px;
}

.log-message {
    color: var(--text-secondary);
    flex: 1;
}

.log-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    font-style: italic;
}

.monitor-actions {
    display: flex;
    gap: 12px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .admin-container {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) auto 1fr;
        grid-template-areas:
            "header"
            "nav"
            "main";
    }

    .admin-nav {
        height: auto;
        flex-direction: row;
        overflow-x: auto;
        padding: var(--space-sm);
        position: relative;
        top: 0;
    }

    .nav-link {
        padding: 8px 12px;
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .admin-main {
        padding: var(--space-md);
    }

    /* Fix: Simulator Frame on Mobile */
    .simulator-frame {
        width: 100%;
        height: 500px;
        transform: none;
        /* Disable zoom */
    }

    /* Fix: Schedule Card Mobile Layout */
    .schedule-card {
        flex-direction: column;
        align-items: flex-start;
        padding: 16px;
    }

    .schedule-info {
        margin-right: 0 !important;
        /* Override JS inline style */
        width: 100%;
    }

    .schedule-card button {
        margin-top: 10px;
    }

    /* Analytics & Other Charts */
    canvas {
        max-width: 100%;
        height: auto !important;
    }

    .dashboard-grid,
    .status-grid {
        grid-template-columns: 1fr;
    }

    /* Fix Run Button Positioning on Mobile */
    .schedule-card>div[style*="absolute"] {
        position: static !important;
        transform: none !important;
        margin-top: 12px;
        width: 100%;
        justify-content: flex-end;
    }

    /* Fix: Pending Approvals Buttons */
    .approval-card .action-buttons {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .approval-card .action-buttons .btn {
        width: 100%;
        margin: 0;
    }

    /* Fix: Changelog Table Overflow */
    .accordion-body {
        overflow-x: auto;
    }

    /* Fix: Status Grid Overflow */
    .status-item {
        min-width: 0;
    }

    /* Fix: Mobile Sidebar/Container Layout */
    .admin-container {
        display: block;
        /* Stack vertically instead of grid */
    }

    .admin-nav {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        flex-direction: row;
        overflow-x: auto;
        padding: 8px;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        gap: 8px;
    }

    .nav-link {
        width: auto;
        white-space: nowrap;
        margin-bottom: 0;
        padding: 8px 12px;
        flex-shrink: 0;
    }

    .admin-main {
        padding: var(--space-md);
    }
}