:root {
    /* Color Palette - Modern Medical / Tech */
    --primary-h: 220;
    --primary-s: 90%;
    --primary-l: 55%;
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-light: hsl(var(--primary-h), var(--primary-s), 90%);
    --primary-dark: hsl(var(--primary-h), var(--primary-s), 30%);
    
    --secondary-h: 180;
    --secondary-s: 100%;
    --secondary-l: 40%;
    --secondary: hsl(var(--secondary-h), var(--secondary-s), var(--secondary-l));
    
    --bg-light: hsl(220, 30%, 98%);
    --bg-dark: hsl(220, 30%, 8%);
    --surface-light: hsl(220, 30%, 100%);
    --surface-dark: hsl(220, 20%, 12%);
    
    --text-main: hsl(220, 20%, 20%);
    --text-muted: hsl(220, 10%, 45%);
    --text-on-primary: #ffffff;
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    /* Shadow */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 16px 48px rgba(0,0,0,0.12);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

html, body {
    height: 100%;
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    overflow-x: hidden;
}

/* Base Elements */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

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

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

/* Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface-dark);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: fixed;
    height: 100vh;
    z-index: 50;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
    overflow: hidden; /* Mantém a sidebar fixa, o scroll será no nav-menu */
}

.app-container.collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    padding: 1.5rem 0.75rem;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 2rem;
    white-space: nowrap;
}

.app-container.collapsed .sidebar-logo {
    justify-content: center;
    gap: 0;
}

.sidebar-logo img {
    height: 40px;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.sidebar-logo span {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: 'Outfit';
    letter-spacing: -0.5px;
    transition: opacity 0.2s ease;
}

.app-container.collapsed .sidebar-logo span {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.nav-menu {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    margin-right: -10px; /* Esconde a scrollbar padrão */
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

/* Scrollbar Customizada para a Sidebar */
.nav-menu::-webkit-scrollbar {
    width: 4px;
}
.nav-menu::-webkit-scrollbar-track {
    background: transparent;
}
.nav-menu::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}
.nav-menu:hover::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.7);
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-container.collapsed .nav-item {
    justify-content: center;
    padding: 12px;
}

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

.nav-item i {
    width: 24px;
    margin-right: 12px;
    font-size: 1.1rem;
    flex-shrink: 0;
    text-align: center;
}

.app-container.collapsed .nav-item i {
    margin-right: 0;
}

.nav-item span {
    transition: opacity 0.2s ease;
}

.app-container.collapsed .nav-item span {
    opacity: 0;
    width: 0;
    pointer-events: none;
}

.nav-section-label {
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.app-container.collapsed .nav-section-label {
    opacity: 0;
    height: 0;
    margin: 0 !important;
}

/* Profile Card Sidebar */
.sidebar-profile-card {
    transition: all 0.3s ease;
}

.app-container.collapsed .sidebar-profile-card {
    padding: 1rem 0 !important;
    justify-content: center !important;
    background: transparent !important;
}

.app-container.collapsed .sidebar-profile-card div:last-child {
    display: none !important;
}

.app-container.collapsed .sidebar-profile-card div:first-child {
    width: 40px !important;
    height: 40px !important;
    margin: 0 !important;
}

/* Main Content */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.app-container.collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

.top-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    z-index: 40;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.app-container.collapsed .top-header {
    left: var(--sidebar-collapsed-width);
}

.content-area {
    padding: 2rem;
    margin-top: var(--header-height);
    flex: 1;
}
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-toggle:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary);
}

/* Components */
.card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    border: 1px solid rgba(0,0,0,0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-modern {
    background: var(--primary);
    color: white;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-modern:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 12px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.3);
}

.btn-modern:disabled {
    background: #ccc;
    cursor: not-allowed;
    box-shadow: none;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-in {
    /* Removido transform e animation daqui para evitar novo stacking context que bloqueia z-index do modal */
}

/* Dark Mode (Preliminary) */
@media (prefers-color-scheme: dark) {
    body {
        background-color: var(--bg-dark);
        color: white;
    }
    .top-header {
        background: var(--surface-dark);
        border-bottom-color: rgba(255,255,255,0.05);
    }
    .card {
        background: var(--surface-dark);
        border-color: rgba(255,255,255,0.05);
    }
    .sidebar-toggle:hover {
        background: rgba(255,255,255,0.05);
    }
}

/* Modal Styles */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999; /* Valor muito alto para garantir sobreposição */
    animation: fadeInModal 0.3s ease forwards;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: slideUpModal 0.3s ease forwards;
}

@keyframes slideUpModal {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

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

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0,0,0,0.1);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsla(var(--primary-h), var(--primary-s), var(--primary-l), 0.1);
}

/* Pagination & Table Utils */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0,0,0,0.05);
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pagination-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-page {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(0,0,0,0.1);
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-page:hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
}

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

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

.table-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.table-action-btn:hover {
    background: rgba(0,0,0,0.05);
    color: var(--primary);
}

.table-action-btn.delete:hover {
    color: #ff6b6b;
    background: rgba(255,107,107,0.1);
}

/* Dark Mode Modal */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: var(--surface-dark);
        border: 1px solid rgba(255,255,255,0.05);
    }
    .form-control {
        background: rgba(255,255,255,0.03);
        border-color: rgba(255,255,255,0.1);
        color: white;
    }
    .form-control:focus {
        background: rgba(255,255,255,0.05);
    }
    .btn-page {
        background: var(--surface-dark);
        border-color: rgba(255,255,255,0.1);
        color: white;
    }
}

/* Blazor Error & Reconnect UI - Premium Styling */
#blazor-error-ui {
    display: none !important;
}

.components-reconnect-modal {
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(4px);
    z-index: 20000 !important;
}

.components-reconnect-modal > div {
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2) !important;
    padding: 2rem !important;
    color: var(--text-main) !important;
    font-family: 'Outfit', sans-serif !important;
    text-align: center !important;
}

.components-reconnect-show, .components-reconnect-failed, .components-reconnect-rejected {
    display: flex !important;
    align-items: center;
    justify-content: center;
}