:root {
    --bg-color: #000022;
    /* Grafite */
    --surface-color: #05052b;
    /* Slightly lighter than Grafite for contrast */
    --primary-color: #0048B7;
    /* Azul Escuro */
    --primary-hover: #003991;
    --accent-color: #FF7701;
    /* Laranja */
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --success-color: #10b981;
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
}

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

a:hover {
    color: var(--primary-hover);
}

/* Layout */
.app-container {
    display: flex;
    flex: 1;
    min-height: 100vh;
    align-items: stretch;
}

.sidebar {
    width: 260px;
    background-color: var(--surface-color);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 1rem;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.card {
    background-color: var(--surface-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
}

.form-group {
    margin-bottom: 1.5rem;
}

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

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Login Specific */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    margin-bottom: 0.5rem;
    display: block;
}

.logo span {
    color: var(--primary-color);
}

/* Dashboard Specific */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.course-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.course-image {
    height: 160px;
    background-color: var(--bg-color);
    border-radius: calc(var(--radius) - 4px);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.progress-bar {
    height: 8px;
    background-color: var(--bg-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background-color: var(--success-color);
    width: 0%;
    transition: width 0.5s ease;
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: white;
}

/* Player Layout */
.player-layout {
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: fixed;
    /* Force fixed to viewport */
    top: 0;
    left: 0;
}

.player-sidebar {
    width: 300px;
    background-color: var(--bg-color);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    height: 100%;
}

.player-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 4rem;
    height: 100%;
}

.tutor-sidebar {
    width: 320px;
    background-color: var(--surface-color);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    /* Internal scroll only */
}

/* Course Navigation */
.phase-item {
    margin-bottom: 1rem;
}

.phase-header-toggle {
    width: 100%;
    padding: 0.5rem 1rem;
    font-weight: 600;
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.03);
    border: none;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 0.95rem;
    text-align: left;
}

.phase-header-toggle:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.phase-chevron {
    transition: transform 0.2s ease;
}

.phase-item.is-collapsed .phase-chevron {
    transform: rotate(-90deg);
}

.phase-item.is-collapsed .phase-steps {
    display: none;
}

.step-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.step-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

.step-link.active {
    background-color: rgba(0, 72, 183, 0.1);
    /* Primary color with opacity */
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.step-link.completed {
    color: #22c55e;
}

.step-link.completed .step-icon {
    color: #22c55e;
}

.step-icon {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
}

/* Video Container */
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    /* 16:9 Aspect Ratio */
    height: 0;
    background-color: black;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Checklist */
.checklist-container {
    background-color: var(--surface-color);
    padding: 1.5rem;
    border-radius: var(--radius);
    margin-top: 2rem;
    border: 1px solid var(--border-color);
}

.checklist-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-item input {
    margin-right: 1rem;
    width: 18px;
    height: 18px;
    accent-color: var(--success-color);
}

/* AI Tutor Chat */
.tutor-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.tutor-avatar {
    width: 32px;
    height: 32px;
    background-color: var(--accent-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 0;
    /* Important for flex scrolling */
}

.message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
}

.message.bot {
    background-color: var(--bg-color);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message.user {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-input-area {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    background-color: var(--surface-color);
    /* Ensure background covers content behind */
    flex-shrink: 0;
    /* Prevent shrinking */
}

.btn-icon {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius);
    width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Navigation Buttons */
.nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-color);
    background-color: var(--surface-color);
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.9rem;
}

.nav-btn:hover:not(.disabled) {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
}

.nav-btn.primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.nav-btn.primary:hover:not(.disabled) {
    background-color: var(--primary-hover);
}

.nav-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Assessment Link */
.assessment-link {
    margin-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 1rem !important;
}

.assessment-link.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.assessment-link.unlocked {
    color: var(--accent-color);
}

.assessment-link.unlocked:hover {
    background-color: rgba(255, 119, 1, 0.1);
    color: var(--accent-color);
}

.assessment-link.completed {
    color: #22c55e !important;
}

/* Global Loader */
.top-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 6px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color), var(--primary-color));
    background-size: 200% 100%;
    z-index: 100001;
    transition: width 0.4s cubic-bezier(0.1, 0.7, 1.0, 0.1);
    box-shadow: 0 0 20px var(--primary-color), 0 0 10px var(--accent-color);
    animation: loaderPulse 2s linear infinite;
}

@keyframes loaderPulse {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: -100% 0;
    }
}

.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 34, 0.8);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    flex-direction: column;
    gap: 1.5rem;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loader-text {
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
}
