/* Estilos globais e variáveis de cores */
:root {
    /* Tema Escuro */
    --bg-dark: #1f2937;
    --bg-medium: #374151;
    --text-light: #f3f4f6;
    --text-prescricao: #f3f4f6;
    --text-badge: #292929;
    --accent-green: #34d399;
    --accent-purple: #c084fc;
    --accent-blue: #60a5fa;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --border-color: #4b5563;
    --hover-bg: #4b5563;
    --danger-red: #bc3232;
    --warning-yellow: #ffd900;
}

/* Tema Claro */
[data-theme='light'] {
    --bg-dark: #e5e7eb;
    --bg-medium: #f9fafb;
    --text-light: #1f2937;
    --text-prescricao: #141414;
    --text-badge: #ffffff;
    --accent-green: #059669;
    --accent-purple: #9333ea;
    --accent-blue: #2563eb;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --border-color: #d1d5db;
    --hover-bg: #e5e7eb;
    --danger-red: #8d0000;
    --warning-yellow: #dea700;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
    display: flex;
    margin: 0;
    transition: all 0.3s ease-in-out;
}

/* Estilos do menu lateral (sidebar) */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 256px; /* 64 * 4px = 256px */
    background-color: var(--bg-medium);
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 40;
    padding: 24px;
}

/* Torna o menu visível quando a classe 'active' é adicionada */
.sidebar.active {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.logo {
    height: 40px;
    width: 40px;
    color: var(--accent-green);
}

.app-title {
    font-size: 1.5rem;
    font-weight: bold;
}

/* Botão para fechar o menu, agora visível em telas pequenas */
.close-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    color: var(--text-light);
    background: none;
    border: none;
    cursor: pointer;
    display: block; /* Garante que o botão de fechar é exibido */
}

.sidebar nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 8px;
    color: var(--text-light);
    text-decoration: none;
    transition: background-color 0.2s;
}

.sidebar nav a:hover {
    background-color: var(--hover-bg);
}

.sidebar nav a svg {
    height: 20px;
    width: 20px;
    margin-right: 12px;
}

/* Estilos do overlay */
.overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 30;
    display: none;
}

/* Estilos do conteúdo principal */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 0; /* REMOVIDO: A margem geral, para maior controle dos filhos */
    transition: all 0.3s ease-in-out;
}

/* Estilos do cabeçalho */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding: 16px; /* ADICIONADO: Padding para o cabeçalho */
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 16px;
}

/* Botão de menu agora com uma cor mais visível em telas pequenas */
.menu-btn {
    color: var(--text-light); /* Alterado para uma cor de texto mais visível */
    background: none;
    border: none;
    cursor: pointer;
    display: block;
    text-align: left !important;
}

.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    font-size: 1.5rem;
}

.main-logo-container {
    display: none;
    margin-bottom: 16px;
}

.main-logo {
    height: 40px;
    width: 40px;
    color: var(--accent-green);
}

.header-title {
    font-size: 2rem;
    font-weight: bold;
}

.search-profile-container {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 8px 16px;
    border-radius: 9999px;
    background-color: var(--bg-medium);
    color: var(--text-light);
    border: none;
    transition: box-shadow 0.3s;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--accent-green);
}

.user-avatar {
    height: 40px;
    width: 40px;
    background-color: var(--border-color);
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
    flex-shrink: 0;
}

/* Estilos da tabela */
.table-section {
    background-color: var(--bg-medium);
    padding: 16px; /* Ajustado para 16px, para ter o mesmo espaçamento do cabeçalho */
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -1px var(--shadow-color);
    margin: 0 16px 24px 16px; /* ADICIONADO: Margens laterais para a tabela */
}

.table-section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
}

thead {
    text-transform: uppercase;
    font-size: 0.875rem;
    font-weight: 600;
    color: #9ca3af;
    border-bottom: 1px solid var(--border-color);
}

th, td {
    padding: 12px 16px;
}

.patient-row {
    border-bottom: 1px solid var(--border-color);
}

.patient-row:last-child {
    border-bottom: none;
}

.status-badge {
    font-size: 0.75rem;
    color: var(--text-badge);
    padding: 4px 8px;
    border-radius: 9999px;
}

.status-active { background-color: var(--accent-green); }
.status-waiting { background-color: #f59e0b; }
.status-inactive { background-color: #ef4444; }

.action-btn {
    color: var(--accent-blue);
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.2s;
}

.action-btn:hover {
    color: var(--text-light);
}

/* Estilos do Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--bg-medium);
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 10px 15px -3px var(--shadow-color);
    position: relative;
    transform: translateY(20px);
    transition: transform 0.3s ease-in-out;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 1.5rem;
    cursor: pointer;
}

/* Estilos do grid do dashboard */
.dashboard-grid {
    display: grid;
    gap: 16px;
    /* Alterado para que as colunas se ajustem automaticamente */
    grid-template-columns: repeat(auto-fit, minmax(200px, 0.8fr));
    margin-bottom: 24px;
    /* Removido o width fixo para o container da caixa */
    width: 95%;
    margin-left: 16px;
    margin-right: 16px;
}

.info-card {
    background-color: var(--bg-medium);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -1px var(--shadow-color);
    text-align: center;
    /* Removido o width fixo para que a caixa se ajuste automaticamente */
}

.info-card h3 {
    font-size: 1rem;
    font-weight: 500;
    color: #9ca3af;
    margin: 0 0 8px;
}

.info-card .number {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--text-light);
    margin: 0;
}

/* Estilos da nova seção do formulário */
.form-section {
    background-color: var(--bg-medium);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -1px var(--shadow-color);
    margin: 0 16px 24px 16px;
}

.form-section h2 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 24px;
}

.form-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.form-field {
    display: flex;
    flex-direction: column;
}

.form-field label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #9ca3af;
    margin-bottom: 8px;
}

.form-field input {
    padding: 10px;
    border-radius: 8px;
    background-color: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-light);
}

.form-field input:focus {
    outline: none;
    border-color: var(--accent-green);
}

.submit-btn {
    background-color: var(--accent-green);
    color: var(--bg-dark);
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 16px;
    width: 100%;
}

.submit-btn:hover {
    background-color: #2ebc83;
}

.submit-btn-danger {
    background-color: var(--danger-red);
    color: var(--bg-dark);
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 16px;
    width: 100%;
}

.submit-btn-danger:hover {
    background-color: #a30000;
}

.submit-btn-warning {
    background-color: var(--warning-yellow);
    color: var(--bg-dark);
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 16px;
    width: 100%;
}

.submit-btn-warning:hover {
    background-color: #ffb700;
    color: rgb(92, 92, 92);
}

/* Estilos do novo dropdown */
.dropdown-menu {
    list-style: none;
    padding-left: 32px !important; /* Recuo para os subitens */
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease-in-out;
    margin-left: 10px;
}

/* Torna o menu dropdown visível quando a classe 'active' está no item pai */
.dropdown.active .dropdown-menu {
    max-height: 200px; /* Um valor alto o suficiente para caber todos os itens */
}

.dropdown-toggle {
    justify-content: space-between;
}

.dropdown-toggle .menu-content {
    display: flex;
    align-items: center;
}

.dropdown-arrow {
    transition: transform 0.3s ease-in-out;
}

.dropdown.active .dropdown-arrow {
    transform: rotate(90deg);
}

/* Estilos para desktop */
@media (min-width: 768px) {
    .sidebar {
        transform: translateX(0);
        position: relative;
    }

    .main-content {
        padding-left: 0;
        margin-left: 25px;
    }

    /* Esconde o botão de fechar em telas grandes */
    .close-btn {
        display: none;
    }

    .overlay {
        display: none;
    }

    .menu-btn {
        display: none;
    }
    
    .main-logo-container {
        display: block;
    }

    .header {
        flex-direction: row;
        justify-content: space-between;
        padding: 16px;
    }
    
    .search-profile-container {
        width: auto;
    }
}