:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --accent-color: #2ecc71;
    --bg-body: #f4f7f6;
    --text-muted: #7f8c8d;
}

body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; margin: 0; display: flex; height: 100vh; background: var(--bg-body); overflow: hidden; }

/* Barra Lateral */
#sidebar { width: 280px; background: var(--secondary-color); color: white; padding: 20px; overflow-y: auto; flex-shrink: 0; box-shadow: 2px 0 5px rgba(0,0,0,0.1); transition: transform 0.3s ease; z-index: 1000; }
#sidebar h2 { font-size: 1.2rem; border-bottom: 1px solid #34495e; padding-bottom: 10px; }

.close-sidebar {
    display: none;
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.instructor-card { background: rgba(255, 255, 255, 0.05); padding: 15px; border-radius: 8px; margin-bottom: 25px; text-align: center; border: 1px solid #34495e; }
.instructor-card h3 { margin: 0; font-size: 1.1rem; color: var(--primary-color); }
.instructor-card p { margin: 5px 0 0; font-size: 0.85rem; color: #bdc3c7; line-height: 1.4; }

.lesson-link { display: block; color: #bdc3c7; text-decoration: none; padding: 12px 10px; border-bottom: 1px solid rgba(255,255,255,0.1); cursor: pointer; transition: 0.2s; border-radius: 4px; }
.lesson-link:hover { color: white; }
.lesson-link.active { color: var(--primary-color); font-weight: bold; }
.lesson-link.completed::after { content: " ✓"; color: var(--accent-color); font-weight: bold; margin-left: 5px; }

/* Área de Conteúdo */
#content { flex-grow: 1; padding: 40px; overflow-y: auto; scroll-behavior: smooth; position: relative; }
.video-container { position: relative; padding-bottom: 56.25%; height: 0; margin-bottom: 20px; }
.video-container iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 8px; }

/* Botões e Navegação */
.controls { display: flex; gap: 15px; margin-top: 25px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.btn { border: none; padding: 12px 20px; border-radius: 5px; cursor: pointer; font-size: 0.95rem; font-weight: 600; transition: 0.3s; text-decoration: none; display: inline-flex; align-items: center; }
.btn-complete { background-color: var(--accent-color); color: white; }
.btn-complete:hover { background-color: #27ae60; }
.btn i {
    margin-right: 8px; /* Espaçamento padrão para ícones em botões */
}
.btn-complete.is-completed { background-color: var(--text-muted); opacity: 0.8; cursor: default; }
.btn-nav { background-color: var(--primary-color); color: white; }
.btn-nav:hover { background-color: #2980b9; }
.btn-nav:disabled { background-color: #bdc3c7; cursor: not-allowed; }

/* Material de Apoio */
.material-download { background: #fff; padding: 15px; border-radius: 8px; border-left: 4px solid var(--primary-color); margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.material-download h3 { margin-top: 0; font-size: 1rem; color: var(--secondary-color); margin-bottom: 10px; }
.btn-material { background-color: var(--secondary-color); color: white; display: inline-flex; align-items: center; gap: 8px; font-size: 0.9rem; padding: 10px 15px; }
.btn-material:hover { background-color: #22303d; }

/* Barra de Progresso */
#progress-container {
    width: 100%;
    height: 15px;
    background-color: rgba(255, 255, 255, 0.1);
    position: relative;
    margin-top: 25px;
    margin-bottom: 25px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
#progress-bar {
    border-radius: 4px;
    height: 100%;
    width: 0%;
    background-color: #2980b9;
    transition: width 0.5s ease-in-out;
    position: absolute; left: 0; top: 0; z-index: 999;
}
#progress-text {
    position: relative; z-index: 1001;
    color: #ecf0f1;
    font-size: 0.65rem;
    font-weight: bold;
}
.hidden { display: none !important; }

/* Administrador */
.admin-only { display: none; margin: 15px 0; padding: 10px; border: 1px dashed var(--primary-color); border-radius: 8px; background: rgba(52, 152, 219, 0.05); }
.admin-only.is-admin { display: block; }
.admin-badge { font-size: 0.7rem; background: var(--primary-color); color: white; padding: 2px 6px; border-radius: 10px; margin-left: 5px; vertical-align: middle; }
.btn-admin-action { background: var(--primary-color); color: white; border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; font-size: 0.8rem; transition: 0.3s; }
.btn-admin-action:hover { background: #2980b9; }
.btn-delete { background-color: #e74c3c; color: white; }
.btn-delete:hover { background-color: #c0392b; }

.admin-lesson-item .item-actions {
    display: flex;
    gap: 8px; /* Espaçamento entre os botões de ação */
}

.admin-lesson-item .item-actions button {
    padding: 6px 10px; /* Ajuste de padding para botões menores */
    font-size: 0.85rem; /* Tamanho de fonte para botões de ação */
    white-space: nowrap; /* Evita que o texto do botão quebre */
}
.admin-lesson-item .item-actions button i {
    margin-right: 5px; /* Espaçamento entre o ícone e o texto */
}

.main-actions { display: flex; gap: 10px; }

/* Estilos para Drag-and-Drop */
.admin-lesson-item {
    background-color: #fff; /* Adicionar fundo para melhor visualização ao arrastar */
    margin-bottom: 5px; /* Espaçamento entre os itens */
    border-radius: 4px;
    cursor: grab; /* Cursor de arrastar */
    transition: background-color 0.2s, box-shadow 0.2s;
    border: 1px solid #eee;
}

.admin-lesson-item:hover { background-color: #f9f9f9; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }

.admin-lesson-item.dragging {
    opacity: 0.5;
    border: 2px dashed var(--primary-color);
    background-color: #e0f2f7; /* Cor de fundo ao arrastar */
}

.admin-lesson-item.drag-over {
    border-top: 2px solid var(--primary-color); /* Indicador visual de onde o item será solto */
    margin-top: 5px;
    margin-bottom: 5px;
}

/* Autenticação */
#auth-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-body);
    display: flex; align-items: center; justify-content: center;
    z-index: 5000;
}
.auth-card {
    background: white; padding: 40px; border-radius: 12px;
    width: 100%; max-width: 400px; box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
}
.auth-card h1 { color: var(--secondary-color); font-size: 1.5rem; margin-bottom: 10px; }
.auth-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 25px; }
.auth-card input {
    width: 100%; padding: 12px; margin-bottom: 15px;
    border: 1px solid #ddd; border-radius: 6px; box-sizing: border-box;
}
.auth-card .btn-auth {
    width: 100%; background: var(--primary-color); color: white;
    border: none; padding: 14px; border-radius: 6px; font-weight: bold;
    cursor: pointer; transition: 0.3s;
}
.auth-card .btn-auth:hover { background: #2980b9; }
.auth-card .toggle-auth {
    margin-top: 20px; font-size: 0.85rem; color: var(--primary-color);
    cursor: pointer; text-decoration: underline;
}
.error-msg { color: #e74c3c; font-size: 0.85rem; margin-bottom: 15px; display: none; }

/* Logout */
.logout-container { padding: 15px; border-top: 1px solid rgba(255,255,255,0.1); margin-top: auto; }
.btn-logout {
    width: 100%; background: transparent; border: 1px solid rgba(255,255,255,0.3);
    color: white; padding: 8px; border-radius: 4px; cursor: pointer; font-size: 0.8rem;
}

/* Animações */
.lesson-section:not(.hidden) { animation: fadeIn 0.5s ease-out forwards; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Animação de Fade-in para o container principal do app */
#app-wrapper:not(.hidden) {
    animation: appFadeIn 0.7s ease-out forwards;
}

@keyframes appFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Modais */
#completion-modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 2000;
    display: none; align-items: center; justify-content: center;
}
.modal-content {
    background: white; padding: 40px; border-radius: 15px; text-align: center;
    max-width: 500px; width: 90%; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.lesson-duration { font-size: 0.75rem; color: #bdc3c7; margin-top: 4px; display: block; }

/* Modal de Edição de Aulas (Admin) */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 2000;
    display: none; align-items: center; justify-content: center;
}
.modal-content {
    background: white; padding: 30px; border-radius: 15px; text-align: center;
    max-width: 1200px; width: 95%; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    position: relative;
    max-height: 90vh; /* Define uma altura máxima de 90% da altura da viewport */
    overflow-y: auto; /* Adiciona uma barra de rolagem vertical se o conteúdo exceder a altura máxima */
}
.close-modal-btn {
    position: absolute; top: 10px; right: 15px;
    background: none; border: none; font-size: 2rem; color: #7f8c8d;
    cursor: pointer;
}
.close-modal-btn:hover { color: #333; }

#admin-lesson-list {
    max-height: 300px; overflow-y: auto; margin-bottom: 20px;
    border: 1px solid #eee; border-radius: 8px; padding: 10px;
    text-align: left;
}

.admin-lesson-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px; border-bottom: 1px solid #eee;
    margin-bottom: 8px; /* Re-adicionado para espaçamento entre os itens */
    background-color: white;
}
.admin-lesson-item:last-child { border-bottom: none; }
.admin-lesson-item span { color: var(--secondary-color); font-weight: 500; }
.admin-lesson-item .item-actions button { margin-left: 10px; padding: 5px 10px; font-size: 0.8rem; }

#lesson-form-container {
    margin-top: 20px; padding-top: 20px; border-top: 1px solid #eee;
}
#lesson-form-container h3 { color: var(--secondary-color); margin-bottom: 20px; }
#lesson-form-container input, #lesson-form-container textarea, #lesson-form-container select {
    width: 100%;
    padding: 12px; margin-bottom: 15px;
    border: 1px solid #ddd; border-radius: 6px; box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #fff;
    transition: border-color 0.2s;
}
#lesson-form-container input:focus, #lesson-form-container textarea:focus, #lesson-form-container select:focus, .btn:focus {
    border-color: var(--primary-color); outline: none;
}
#lesson-form-container textarea {
    min-height: 80px; resize: vertical;
}
.form-actions {
    display: flex; justify-content: space-between; align-items: center; margin-top: 10px;
}
.form-actions .btn {
    padding: 10px 15px; font-size: 0.9rem;
}

/* Tabela de Médicos */
.table-container {
    margin-top: 30px;
    border-radius: 8px;
    border: 1px solid #eee;
    overflow: hidden;
}
#doctors-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}
#doctors-table th, #doctors-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
    font-size: 0.85rem;
}
#doctors-table th {
    background-color: var(--secondary-color);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    
}

.status-active {
   background:#dcfce7;
   color:#15803d;
}

.status-pending {
   background:#fef3c7;
   color:#b45309;
}

.status-suspended {
   background:#fee2e2;
   color:#dc2626;
}

/* Spinner de Carregamento */
#loading-spinner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8); /* Fundo semi-transparente */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000; /* Acima de tudo, mas abaixo da tela de auth */
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color); /* Cor do spinner */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Responsivo */
.mobile-header {
    display: none;
    background: var(--secondary-color);
    color: white;
    padding: 15px 20px;
    align-items: center;
    justify-content: flex-start;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: fixed; top: 0; width: 100%; z-index: 900;
    box-sizing: border-box;
}
.menu-toggle { 
    background: var(--primary-color); border: none; color: white; 
    font-size: 1.2rem; cursor: pointer; padding: 6px 12px; border-radius: 4px;
    display: flex; align-items: center; gap: 8px;
}
.menu-toggle::after { content: "MENU"; font-size: 0.8rem; font-weight: bold; }

#overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 950;
}

@media (max-width: 768px) {
    body { flex-direction: column; }
    .mobile-header { display: flex; }
    #sidebar {
        position: fixed; left: 0; top: 0; height: 100vh;
        transform: translateX(-100%);
        padding-top: 50px;
    }
    #sidebar.open { transform: translateX(0); }
    .close-sidebar { display: block; }
    #content { padding: 80px 20px 20px; }
    .controls { flex-direction: column; align-items: stretch; }
    .btn { justify-content: center; }
}

#profile-section h1 { color: var(--secondary-color); margin-bottom: 20px; }

/* Grid de Perfil */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 600px) {
    .profile-grid { grid-template-columns: 1fr; }
}

.profile-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
}

.profile-group label {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-group span {
    font-size: 1.05rem;
    color: var(--secondary-color);
    font-weight: 500;
}

.profile-group input, .profile-group select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    width: 100%;
    box-sizing: border-box;
    background: #fff;
}

/* Estilos para Foto de Perfil */
.profile-photo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}

#profile-photo-val {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
    background-color: #eee;
}

.pulse-effect {
    animation: pulse-animation 2s infinite;
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
}

@keyframes pulse-animation {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

/* Utilitários de Layout Admin */
.admin-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    text-align: left;
}
.admin-form-grid .full-width { grid-column: span 2; }
.admin-form-group { display: flex; flex-direction: column; gap: 5px; }
.admin-form-group label { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }

/* Badges de Status */
.badge {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: bold;
    text-transform: uppercase;
    display: inline-block;
}
.badge-published { background: #e8f5e9; color: #2e7d32; }
.badge-draft { background: #fff3e0; color: #ef6c00; }
.badge-active { background: #e3f2fd; color: #1565c0; }

#doctors-table tbody tr:hover {
    background-color: #f8f9fa;
}