/* Digital Heroes SOP & Training Styles - AI Training Edition */

/* Dark theme (default) */
:root {
    --primary: #8B5CF6;
    --primary-dark: #7C3AED;
    --secondary: #A78BFA;
    --background: #0F172A;
    --surface: #1E293B;
    --surface-hover: #334155;
    --text: #F8FAFC;
    --text-muted: #94A3B8;
    --danger: #EF4444;
    --success: #22C55E;
    --warning: #F59E0B;
}

/* Light theme (toggle) */
body.light-mode {
    --primary: #7C3AED;
    --primary-dark: #5B21B6;
    --secondary: #6D28D9;
    --background: #F8FAFC;
    --surface: #FFFFFF;
    --surface-hover: #E2E8F0;
    --text: #1E293B;
    --text-muted: #64748B;
}

/* Animation for auto-advance progress */
@keyframes progressAnim {
    from {
        width: 0%;
    }

    to {
        width: 100%;
    }
}

/* Hardware acceleration fixes for smoother performance on MacBook */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.sidebar,
.main-content,
.task-card,
.nav-btn,
.option-btn {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text);
    font-weight: 700;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.8rem;
    border-bottom: 2px solid var(--surface-hover);
    padding-bottom: 0.5rem;
    margin-top: 2rem;
}

h3 {
    font-size: 1.4rem;
    color: var(--primary);
    margin-top: 1.5rem;
}

p,
li {
    color: var(--text-muted);
}

body.dark-mode p,
body.dark-mode li {
    color: #CBD5E1;
}

ul {
    padding-left: 1.5rem;
}

li {
    margin-bottom: 0.5rem;
}

/* Content Sections */
.content-section {
    background: var(--surface);
    border: 1px solid var(--surface-hover);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
}

.content-section {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

body.light-mode .content-section {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.06);
}

/* Feature Boxes */
.highlight-box {
    background: rgba(20, 184, 166, 0.1);
    border-left: 4px solid var(--primary);
    padding: 1.5rem;
    border-radius: 0 8px 8px 0;
    margin: 1.5rem 0;
}

.warning-box {
    background: rgba(245, 158, 11, 0.1);
    border-left: 4px solid var(--warning);
    padding: 1.5rem;
    border-radius: 0 8px 8px 0;
    margin: 1.5rem 0;
}

.warning-box strong,
.highlight-box strong {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 1.1em;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--surface-hover);
    margin: 1rem 0;
}

/* Buttons */
.nav-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #000;
    font-weight: 600;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.nav-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.3);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.back-btn {
    background: transparent;
    border: 1px solid var(--surface-hover);
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.back-btn:hover {
    border-color: var(--text);
    color: var(--text);
}

/* Quiz Styles */
.option-btn {
    width: 100%;
    text-align: left;
    background: var(--surface-hover);
    border: 1px solid transparent;
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    background: #475569;
}

body.light-mode .option-btn:hover {
    background: #CBD5E1;
}

.option-btn.selected {
    background: rgba(20, 184, 166, 0.2);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

/* Study Guide */
.study-guide {
    background: linear-gradient(to right, rgba(15, 23, 42, 1), rgba(30, 41, 59, 1));
    border: 1px solid var(--surface-hover);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

body.light-mode .study-guide {
    background: linear-gradient(to right, #F1F5F9, #E2E8F0);
}

.study-guide h4 {
    color: var(--secondary);
    margin-top: 0;
}

.study-guide ul {
    margin-bottom: 0;
}

.study-guide li {
    color: var(--text-muted);
}

/* ==================== */
/* LAYOUT SYSTEM        */
/* ==================== */

.training-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.training-header {
    height: 70px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-hover);
    flex-shrink: 0;
    gap: 12px;
    overflow: hidden;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.home-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 8px 14px;
    background: rgba(20, 184, 166, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(20, 184, 166, 0.3);
    transition: all 0.2s;
    flex-shrink: 0;
}

.home-link:hover {
    background: rgba(20, 184, 166, 0.2);
    border-color: var(--primary);
}

.training-header h1 {
    font-size: 1.3rem;
    margin: 0;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.training-header h1::before {
    content: '🎓 ';
}

.header-right {
    flex-shrink: 0;
}

.header-right p {
    margin: 0;
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    white-space: nowrap;
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: 1px solid var(--surface-hover);
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
}

/* Brand Logo - hidden on mobile, we use Home text instead */
.brand-logo {
    display: none;
}

/* Layout Container */
.layout-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* ==================== */
/* SIDEBAR              */
/* ==================== */

.sidebar {
    width: 300px;
    min-width: 300px;
    background: var(--surface);
    border-right: 1px solid var(--surface-hover);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Progress Bar */
.progress-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--surface-hover);
    border-radius: 12px;
    padding: 16px;
}

body.light-mode .progress-container {
    background: rgba(0, 0, 0, 0.05);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 10px;
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
}

body.light-mode .progress-bar {
    background: rgba(0, 0, 0, 0.08);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.5s ease;
    border-radius: 10px;
}

/* Task Cards */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-card {
    padding: 12px 14px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.task-card:hover:not(.locked) {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--surface-hover);
}

body.light-mode .task-card {
    background: rgba(0, 0, 0, 0.02);
}

body.light-mode .task-card:hover:not(.locked) {
    background: rgba(0, 0, 0, 0.05);
}

.task-card.current {
    background: rgba(20, 184, 166, 0.1);
    border-color: var(--primary);
}

.task-card.completed {
    opacity: 0.75;
}

.task-card.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.task-number {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--surface-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8em;
    color: var(--text-muted);
    flex-shrink: 0;
}

.task-card.current .task-number,
.task-card.completed .task-number {
    background: var(--primary);
    color: var(--background);
}

.task-info {
    flex: 1;
    min-width: 0;
}

.task-info h3 {
    margin: 0;
    font-size: 0.85em;
    color: var(--text);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-info p {
    margin: 2px 0 0 0;
    font-size: 0.7em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-status {
    font-size: 0.9em;
    color: var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 32px 48px;
    overflow-y: auto;
    max-width: none;
}

.task-view-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Sidebar Overlay (for mobile) */
.sidebar-overlay {
    display: none;
}

/* ==================== */
/* RESPONSIVE / MOBILE  */
/* ==================== */

/* Medium screens - hide certification text */
@media (max-width: 1100px) {
    .header-right {
        display: none;
    }

    .training-header h1 {
        font-size: 1.1rem;
    }
}

@media (max-width: 900px) {
    .training-header {
        padding: 0 16px;
        height: 60px;
    }

    .mobile-menu-btn {
        display: block !important;
    }

    .training-header h1 {
        font-size: 1rem;
    }

    .header-right {
        display: none;
    }

    .layout-container {
        position: relative;
    }

    .sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 85%;
        max-width: 320px;
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 5px 0 20px rgba(0, 0, 0, 0.5);
        transition: transform 0.3s ease;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 900;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

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

    .main-content {
        padding: 20px;
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 500px) {
    .training-header h1 {
        display: none;
    }

    .home-link span:last-child {
        display: none;
    }
}

/* ==================== */
/* QA BUG FIXES         */
/* ==================== */

/* Issue #21: Progress bar overflow guard */
.progress-fill {
    max-width: 100%;
}

/* Issue #11/#25: Responsive YouTube iframes */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    margin: 1.5rem 0;
    border-radius: 8px;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 8px;
}

/* Fallback: Make bare iframes responsive even without wrapper */
iframe[src*="youtube"] {
    max-width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border-radius: 8px;
}

/* Issue #22: Header text overflow protection */
.header-right p {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Issue #26: Mobile sidebar close button */
@media (max-width: 900px) {
    .sidebar-close-btn {
        display: flex !important;
    }

    .sidebar {
        padding-top: 50px;
    }
}

/* Issue #24: Timer mobile positioning */
@media (max-width: 900px) {
    #quizTimer {
        top: 70px !important;
        right: 10px !important;
        font-size: 0.9em !important;
        padding: 6px 12px !important;
        z-index: 10001 !important;
    }
}

/* Issue #27: Table mobile improvements */
@media (max-width: 600px) {
    table {
        font-size: 0.85em;
    }

    th, td {
        padding: 8px 6px;
        min-width: 80px;
    }
}

/* Issue #13: Quiz validation feedback animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Issue #35: Certificate modal focus styles */
#certificateModal:focus {
    outline: 2px solid #2DD4BF;
    outline-offset: -2px;
}

/* Theme toggle button */
#training-theme-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--surface-hover);
    background: var(--surface);
    color: var(--text);
    font-size: 1.2em;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    transition: all 0.2s;
}

#training-theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* Welcome screen - auto-hide when task loads */
.welcome-screen {
    transition: opacity 0.3s;
}