:root {
    /* Cores Oficiais */
    --primary-blue: #596589;
    --primary-black: #342028;
    --secondary-gray: #727375;
    --bg-light: #FEFEFE;

    /* Variaveis Funcionais */
    --text-main: var(--primary-black);
    --text-muted: var(--secondary-gray);
    --accent: var(--primary-blue);
    --bg-page: #F8FAFC;
    --surface: #FFFFFF;
    --border-ui: rgba(52, 32, 40, 0.12);

    /* Title Colors */
    --title-color: #1e3a8a;
    /* Dark Blue (Blue 900) - Distinct from brand blue for better contrast */
}

.dark {
    /* Branding colors adaption for Dark Mode */
    --primary-black: #F4F4F5;
    /* Redefine primary-black to be white/light in dark mode */

    --text-main: var(--primary-black);
    --text-muted: #A1A1AA;
    --bg-page: #09090B;
    --surface: #18181B;
    --border-ui: rgba(255, 255, 255, 0.12);

    /* Dark Mode Title - White */
    --title-color: #FFFFFF;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Segoe UI', 'Inter', sans-serif;
    color: var(--title-color);
    font-weight: 700;
}

.layout-container {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
}

/* Top Bar */
.topbar {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border-ui);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background-color: var(--primary-blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.brand-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-black);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dark .brand-text {
    color: #FFFFFFFF;
}

/* Nav Links */
.nav-link {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--accent);
    background-color: rgba(89, 101, 137, 0.05);
}

.btn-theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
    cursor: pointer;
}

.btn-theme-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

.dark .btn-theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Main Content */
.main-content {
    box-sizing: border-box;
    padding: 32px 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    transition: margin-left 0.3s ease;
}

/* Desktop: Sidebar is visible, push content */
@media (min-width: 1024px) {
    .main-content {
        margin-left: 280px;
        /* Width of sidebar */
        max-width: calc(100% - 280px);
        /* Adjust max-width */
    }

    .sidebar {
        transform: translateX(0) !important;
    }

    .menu-toggle {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    /* Full height */
    left: 0;
    bottom: 0;
    height: 100vh;
    width: 280px;
    background-color: var(--surface);
    border-right: 1px solid var(--border-ui);
    z-index: 40;
    transform: translateX(-100%);
    /* Hidden by default on mobile (slide to left) */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 16px 24px 24px 24px;
}

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

/* Scroll invisível no menu lateral */
.sidebar nav {
    overflow-y: auto;
    min-height: 0; /* Impede que o flex item expanda além do pai */
    scrollbar-width: none; /* Firefox */
}

.sidebar nav::-webkit-scrollbar {
    display: none; /* Chrome / Safari */
}

/* Utility: esconde scrollbar mantendo scroll funcional */
.scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;
}

/* Mobile Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

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

/* Menu Items */
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    border-radius: 8px;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.menu-item:hover {
    background-color: rgba(89, 101, 137, 0.08);
    /* brand blue tint */
    color: var(--accent);
}

.menu-item.active {
    background-color: rgba(89, 101, 137, 0.12);
    color: var(--accent);
    font-weight: 600;
}

.menu-item i {
    font-size: 18px;
}

.menu-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    margin: 24px 0 12px 12px;
    opacity: 0.7;
}

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

/* Card Component */
.card-base {
    background-color: var(--surface);
    border: 1px solid var(--border-ui);
    border-radius: 0.75rem;
    /* rounded-xl */
    padding: 1rem;
    /* p-4 */
    transition: all 0.2s;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.card-hover:hover {
    border-color: var(--primary-blue);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Icon Box Component */
.icon-box {
    padding: 0.625rem;
    /* p-2.5 */
    border-radius: 0.5rem;
    /* rounded-lg */
    background-color: var(--bg-page);
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card-base:hover .icon-box {
    background-color: rgba(89, 101, 137, 0.05);
    /* primary-blue / 5 */
}

/* Typography Components */
.text-title {
    font-size: 0.875rem;
    /* text-sm */
    font-weight: 600;
    color: var(--title-color);
    line-height: 1.25;
    margin-bottom: 0.375rem;
    /* mb-1.5 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1.25rem;
    /* gap-x-5 */
    font-size: 11px;
    color: var(--text-muted);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    /* gap-1.5 */
    font-family: monospace;
    letter-spacing: -0.025em;
}

/* Badge Component */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    /* gap-2 */
    font-size: 10px;
    font-weight: 700;
    padding: 0.125rem 0.5rem;
    /* px-2 py-0.5 */
    border-radius: 0.375rem;
    /* rounded-md */
    line-height: 1;
}

.badge-red {
    color: #ef4444;
    /* text-red-500 */
    background-color: rgba(239, 68, 68, 0.1);
    /* bg-red-500/10 */
}

.badge-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 9999px;
    background-color: currentColor;
}

/* Action Button */
.btn-icon-action {
    padding: 0.5rem;
    /* p-2 */
    border-radius: 0.5rem;
    /* rounded-lg */
    color: var(--text-muted);
    transition: all 0.2s;
}

.btn-icon-action:hover {
    background-color: rgba(89, 101, 137, 0.1);
    color: var(--primary-blue);
}

/* Card Internal Layout Helpers (Replacing Tailwind for dynamic content reliability) */
.card-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    /* gap-4 */
    flex: 1;
    min-width: 0;
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* gap-3 */
    flex-shrink: 0;
}

/* Text & State Helpers */
.text-warning {
    color: #ea580c;
    /* orange-600 */
    opacity: 0.9;
}

.text-meta-icon {
    color: var(--text-muted);
    opacity: 0.7;
}

.group-hover-text-primary {
    transition: color 0.2s;
}

.card-base:hover .group-hover-text-primary {
    color: var(--primary-blue);
}

/* =========================================
   Course Navigation Sidebar (Right)
   ========================================= */

/* Course Nav Overlay (Mobile) */
.course-nav-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 45;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.course-nav-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Course Navigation Sidebar */
.course-nav {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    width: 320px;
    background-color: var(--surface);
    border-left: 1px solid var(--border-ui);
    z-index: 50;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.course-nav.open {
    transform: translateX(0);
}

/* Desktop: Always visible on the right */
@media (min-width: 1024px) {
    .course-nav {
        transform: translateX(0) !important;
    }

    .course-nav-overlay {
        display: none !important;
    }

    .course-nav {
        top: 64px;
        /* Height of mobile header */
        height: calc(100vh - 64px);
    }
}

/* Course Nav Header */
.course-nav-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-ui);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.course-nav-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--title-color);
    margin: 0;
}

.course-nav-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: all 0.2s;
    cursor: pointer;
    background: none;
    border: none;
}

.course-nav-close:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-main);
}

.dark .course-nav-close:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Course Nav Body */
.course-nav-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

/* Course Nav Section */
.course-nav-section {
    margin-bottom: 16px;
}

.course-nav-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--title-color);
    background-color: var(--bg-page);
    border-radius: 8px;
    margin-bottom: 4px;
}

.course-nav-section-header i {
    font-size: 16px;
    color: var(--primary-blue);
}

.course-nav-section-content {
    padding-left: 8px;
}

/* Course Nav Item */
.course-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-muted);
    transition: all 0.2s;
    text-decoration: none;
}

.course-nav-item:hover {
    background-color: rgba(89, 101, 137, 0.08);
    color: var(--accent);
}

.course-nav-item.active {
    background-color: rgba(89, 101, 137, 0.12);
    color: var(--accent);
    font-weight: 600;
}

.course-nav-item-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.course-nav-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Course Nav Empty State */
.course-nav-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.course-nav-empty i {
    font-size: 32px;
    opacity: 0.3;
}

/* =========================================
   Content Embed Styles
   ========================================= */



.content-embed-iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.content-embed-video {
    width: 100%;
    max-height: 70vh;
    background-color: #000;
}

/* Desktop Toggle Support - Sidebar can be collapsed */
@media (min-width: 1024px) {
    .course-nav {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* When sidebar is collapsed, hide it to the right */
    .course-nav:not(.open) {
        transform: translateX(100%) !important;
    }

    /* Adjust main content margin when sidebar is hidden */
    body:has(.course-nav:not(.open)) .main-content {
        margin-right: 0;
        max-width: calc(100% - 280px);
        /* Only left sidebar */
    }

    /* Show toggle button on desktop too */
    #course-nav-toggle,
    #course-nav-toggle-viewer {
        display: flex !important;
    }
}

/* Floating Toggle Button */
.floating-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-blue) 0%, #4a5c7d 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(89, 101, 137, 0.3), 0 8px 24px rgba(89, 101, 137, 0.2);
    cursor: pointer;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInUp 0.5s ease-out;
}

.floating-toggle-btn:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(89, 101, 137, 0.4), 0 12px 32px rgba(89, 101, 137, 0.3);
    background: linear-gradient(135deg, #4a5c7d 0%, var(--primary-blue) 100%);
}

.floating-toggle-btn:active {
    transform: translateY(-2px);
}

.floating-toggle-text {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: -2px;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

@media (max-width:768px) {
    .floating-toggle-btn {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
    }

    .floating-toggle-text {
        font-size: 8px;
    }
}




@media (min-width:1024px) {
    .course-nav {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .course-nav:not(.open) {
        transform: translateX(100%) !important;
    }

    body:has(.course-nav:not(.open)) .main-content {
        margin-right: 0;
        max-width: calc(100% - 280px);
    }
}

/* Collapsed Sidebar Toggle (Floating) */
.sidebar-toggle-collapsed {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 60px;
    height: 160px;
    background-color: var(--surface);
    border: 1px solid var(--border-ui);
    border-right: none;
    border-radius: 12px 0 0 12px;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    z-index: 100;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
}

.sidebar-toggle-collapsed:hover {
    width: 70px;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.15);
}

.sidebar-toggle-handle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background-color: var(--primary-blue);
    border-radius: 12px 0 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: all 0.3s;
}

.sidebar-toggle-collapsed:hover .sidebar-toggle-handle {
    background-color: #4a5c7d;
}

.sidebar-toggle-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-left: 8px;
}

.sidebar-toggle-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background-color: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.sidebar-toggle-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

/* Mobile: make it smaller and at bottom */
@media (max-width: 768px) {
    .sidebar-toggle-collapsed {
        top: auto;
        bottom: 20px;
        width: 50px;
        height: 120px;
        transform: none;
    }

    .sidebar-toggle-handle {
        top: 0;
        transform: translateY(0);
        width: 100%;
        height: 20px;
        border-radius: 12px 12px 0 0;
        flex-direction: column;
    }

    .sidebar-toggle-handle i {
        transform: rotate(-90deg);
    }

    .sidebar-toggle-content {
        margin-left: 0;
        margin-top: 8px;
    }
}

/* Hide floating button when sidebar is open */


/* Side-by-side fix for older overrides */
.course-nav.open~.sidebar-toggle-collapsed {
    display: none;
}

/* Responsive Content Embeds */
.content-embed-container {
    position: relative;
    /* Calculated width: Max 100%, but constrained so height doesn't exceed screen height - headers (~220px) */
    /* h = w * 9/16  =>  w = h * 16/9 */
    /* target max height = 100vh - 220px */
    width: min(100%, calc((100vh - 220px) * 1.777));
    max-width: 650px;
    /* Reduced to ~half size */
    aspect-ratio: 16/9;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    background: #000;
}

/* Container background override for PDF/Files if needed (can be handled inline or via separate class if differentiated) */
/* Ideally PDF container shouldn't be black, but template uses .bg-[--bg-page] or .bg-black. HTML handles bg. */

/* MP4 Videos */
.content-embed-video {
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    max-height: 80vh;
    object-fit: contain;
}

/* Youtube/Vimeo Iframes */
.content-embed-iframe[src*="youtube.com"],
.content-embed-iframe[src*="youtu.be"],
.content-embed-iframe[src*="vimeo.com"] {
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    max-height: 80vh;
    object-fit: contain;
}

/* PDF Iframes (Fallback for others) */
.content-embed-iframe:not([src*="youtube.com"]):not([src*="youtu.be"]):not([src*="vimeo.com"]) {
    width: 100%;
    height: 80vh;
    /* Taller for documents */
    background: white;
}

/* =========================================
   Form Controls
   ========================================= */

.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text-main);
    background-color: var(--bg-page);
    background-clip: padding-box;
    border: 1px solid var(--border-ui);
    border-radius: 0.5rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    display: block;
}

.form-control:focus {
    color: var(--text-main);
    background-color: var(--bg-page);
    border-color: var(--primary-blue);
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(89, 101, 137, 0.25);
}

.form-control::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

/* Disabled state */
.form-control:disabled,
.form-control[readonly] {
    background-color: rgba(0, 0, 0, 0.05);
    opacity: 0.7;
    cursor: not-allowed;
}

.dark .form-control:disabled,
.dark .form-control[readonly] {
    background-color: rgba(255, 255, 255, 0.05);
}

/* File Input Styling */
input[type="file"].form-control {
    padding: 0.375rem 0;
    /* Adjust vertical padding */
    padding-left: 0.5rem;
    /* Left padding for content */
    display: flex;
    align-items: center;
}

input[type="file"]::file-selector-button {
    margin-right: 1rem;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
    background-color: var(--surface);
    color: var(--text-main);
    border: 1px solid var(--border-ui);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    line-height: 1.5;
}

input[type="file"]::file-selector-button:hover {
    background-color: rgba(89, 101, 137, 0.05);
    border-color: var(--primary-blue);
    color: var(--primary-blue);
}

/* Remove default focus outline on file button in some browsers */
input[type="file"]:focus::file-selector-button {
    outline: none;
    border-color: var(--primary-blue);
}