*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: #111827;
}

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== Sidebar ===== */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px;
    background: #111827;
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.25s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #1f2937;
}

.sidebar-logo {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem;
    line-height: 1;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #1f2937;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    flex-shrink: 0;
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    overflow: hidden;
}

.sidebar-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #f9fafb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.sidebar-section-label {
    display: block;
    padding: 0.75rem 1.25rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    color: #d1d5db;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: #1f2937;
    color: #f9fafb;
    text-decoration: none;
}

.sidebar-link.active {
    background: #1f2937;
    color: #60a5fa;
    border-left-color: #60a5fa;
    font-weight: 600;
}

.sidebar-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-footer {
    border-top: 1px solid #1f2937;
    padding: 0.5rem 0;
}

.sidebar-link-logout {
    color: #f87171;
}

.sidebar-link-logout:hover {
    background: #1f2937;
    color: #fca5a5;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
}

/* ===== Main wrapper (with sidebar) ===== */

.has-sidebar .main-wrapper {
    margin-left: 250px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.has-sidebar .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.75rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.has-sidebar .topbar-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
}

.hamburger {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.3rem;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #374151;
    border-radius: 2px;
    transition: transform 0.2s ease;
}

.has-sidebar .page-container {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 1.5rem auto 3rem;
    padding: 0 1.5rem;
}

.has-sidebar .footer {
    margin-left: 0;
}

/* ===== Topbar (no sidebar: public/student pages) ===== */

body:not(.has-sidebar) .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: #111827;
    color: #f9fafb;
    padding: 0.5rem 1.5rem;
}

body:not(.has-sidebar) .topbar-inner {
    max-width: 960px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-weight: 600;
}

.topbar-nav a {
    margin-left: 1rem;
    color: #e5e7eb;
    font-size: 0.9rem;
}

.topbar-nav a:hover {
    color: #ffffff;
}

body:not(.has-sidebar) .page-container {
    max-width: 960px;
    margin: 1.5rem auto 3rem;
    padding: 0 1rem;
}

/* ===== Card ===== */

.card {
    background: #ffffff;
    border-radius: 0.75rem;
    padding: 1.5rem 1.75rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
    margin-bottom: 1.5rem;
}

.card-light {
    background: #f9fafb;
}

.card-narrow {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

h1 {
    margin-top: 0;
    font-size: 1.6rem;
}

h2 {
    margin-top: 0;
    font-size: 1.3rem;
}

/* ===== Grid ===== */

.grid {
    display: grid;
    gap: 1.25rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

/* ===== Button ===== */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.2rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.95rem;
    cursor: pointer;
    background: #e5e7eb;
    color: #111827;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

.button.primary {
    background: #2563eb;
    color: #f9fafb;
    box-shadow: 0 8px 16px rgba(37, 99, 235, 0.3);
}

.button.secondary {
    background: #111827;
    color: #f9fafb;
}

.button.danger {
    background: #dc2626;
    color: #f9fafb;
}

.button.warning {
    background: #ea580c;
    color: #f9fafb;
}

.button.success {
    background: #16a34a;
    color: #f9fafb;
}

.button.small {
    padding: 0.35rem 0.8rem;
    font-size: 0.8rem;
}

.button:hover {
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 8px 15px rgba(15, 23, 42, 0.16);
}

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

.form-grid {
    display: grid;
    gap: 1rem 1.25rem;
}

.form-grid-2col {
    grid-template-columns: 1fr 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.form-group-full {
    grid-column: 1 / -1;
}

label {
    font-size: 0.9rem;
    font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
select,
textarea {
    padding: 0.55rem 0.65rem;
    border-radius: 0.5rem;
    border: 1px solid #d1d5db;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
    resize: vertical;
    min-height: 60px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 1px #2563eb33;
}

.form-actions {
    margin-top: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ===== Alert ===== */

.alert {
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #ecfdf5;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* ===== Table ===== */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th,
td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

th {
    background: #f9fafb;
    font-weight: 600;
}

.text-muted {
    font-size: 0.85rem;
    color: #6b7280;
}

/* ===== Breadcrumb ===== */

.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
}

.breadcrumb a {
    color: #2563eb;
}

.breadcrumb-sep::before {
    content: '/';
    margin: 0 0.15rem;
    color: #9ca3af;
}

/* ===== Quiz ===== */

.quiz-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quiz-question {
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    padding: 0.75rem 1rem;
}

.quiz-question legend {
    font-weight: 600;
    padding: 0 0.25rem;
}

.quiz-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.35rem;
    padding: 0.35rem 0.45rem;
    border-radius: 0.5rem;
    cursor: pointer;
}

.quiz-option:hover {
    background: #f3f4f6;
}

.quiz-option input[type="radio"] {
    margin-top: 0.2rem;
}

.quiz-option-letter {
    font-weight: 600;
    min-width: 1.4rem;
}

.quiz-serie h2 {
    margin-bottom: 0.5rem;
}

.quiz-yesno {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.4rem 0;
    border-bottom: 1px dashed #e5e7eb;
}

.quiz-yesno:last-child {
    border-bottom: none;
}

.yesno-group {
    display: flex;
    gap: 0.75rem;
    white-space: nowrap;
}

.footer {
    text-align: center;
    padding: 1rem 0.5rem 1.5rem;
    font-size: 0.8rem;
    color: #6b7280;
}

.canal-descricao {
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    margin-bottom: 1rem;
}

.canal-destaque {
    border-color: #2563eb;
    background: #eff6ff;
}

/* ===== Admin Panel ===== */

.grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.grid-5 {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.admin-summary {
    margin-bottom: 0;
}

.summary-card {
    text-align: center;
    padding: 1.25rem 1rem;
    border-left: 4px solid #e5e7eb;
}

.summary-card .summary-number {
    display: block;
    font-size: 2.2rem;
    font-weight: 700;
    line-height: 1;
}

.summary-card .summary-label {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: #6b7280;
}

.summary-cursos { border-left-color: #8b5cf6; }
.summary-cursos .summary-number { color: #8b5cf6; }

.summary-turmas { border-left-color: #6366f1; }
.summary-turmas .summary-number { color: #6366f1; }

.summary-alunos { border-left-color: #2563eb; }
.summary-alunos .summary-number { color: #2563eb; }

.summary-responderam { border-left-color: #16a34a; }
.summary-responderam .summary-number { color: #16a34a; }

.summary-pendentes { border-left-color: #ea580c; }
.summary-pendentes .summary-number { color: #ea580c; }

.turma-progress-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.turma-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.3rem;
}

.progress-bar {
    height: 10px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #60a5fa);
    border-radius: 999px;
    transition: width 0.6s ease;
}

.progress-complete {
    background: linear-gradient(90deg, #16a34a, #4ade80);
}

.chart-container {
    max-width: 480px;
    margin: 0 auto 1rem;
}

.canal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 0.5rem;
}

.canal-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
}

.canal-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.canal-dot-visual { background: #6366f1; }
.canal-dot-auditivo { background: #f59e0b; }
.canal-dot-cinestesico { background: #10b981; }
.canal-dot-visual-auditivo,
.canal-dot-visual-cinestesico,
.canal-dot-auditivo-cinestesico,
.canal-dot-visual-auditivo-cinestesico {
    background: linear-gradient(135deg, #6366f1, #f59e0b, #10b981);
}

.admin-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
}

.admin-filter .form-group {
    min-width: 200px;
    flex: 1;
}

/* ===== Badges ===== */

.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-warning {
    background: #fff7ed;
    color: #9a3412;
}

.badge-inactive {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}

.badge-master {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.badge-admin-role {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ===== Canal Tags ===== */

.canal-tag {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.canal-tag-visual { background: #eef2ff; color: #4338ca; }
.canal-tag-auditivo { background: #fffbeb; color: #b45309; }
.canal-tag-cinestesico { background: #ecfdf5; color: #047857; }
.canal-tag-visual-auditivo,
.canal-tag-visual-cinestesico,
.canal-tag-auditivo-cinestesico,
.canal-tag-visual-auditivo-cinestesico {
    background: #f5f3ff;
    color: #5b21b6;
}

/* ===== Row states ===== */

.row-pendente { opacity: 0.65; }
.row-inativo { opacity: 0.45; background: #f9fafb; }

/* ===== Ações ===== */

.acoes-cell {
    white-space: nowrap;
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

.admin-export {
    margin-top: 1rem;
    display: flex;
    gap: 0.5rem;
}

/* ===== Setup Page ===== */

.setup-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.setup-icon {
    display: inline-block;
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: 0.25rem;
    color: #2563eb;
}

.setup-header h1 {
    margin-bottom: 0;
}

/* ===== Empty State ===== */

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #6b7280;
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.empty-state p {
    margin: 0.5rem 0;
}

/* ===== Info Count ===== */

.info-count {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: #f3f4f6;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 600;
}

/* ===== Responsive ===== */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    .sidebar-close {
        display: block;
    }

    .sidebar-overlay.visible {
        display: block;
    }

    .has-sidebar .main-wrapper {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

    .form-grid-2col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .quiz-yesno {
        flex-direction: column;
        align-items: flex-start;
    }

    .admin-filter {
        flex-direction: column;
    }

    .turma-progress-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }
}
