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

:root {
    --cd-primary: #004983;
    --cd-primary-container: #28619e;
    --cd-on-primary: #ffffff;
    --cd-background: #f7f9fc;
    --cd-on-surface: #191c1e;
    --cd-on-surface-variant: #424752;
    --cd-surface: #f7f9fc;
    --cd-surface-container: #eceef1;
    --cd-surface-container-low: #f2f4f7;
    --cd-surface-container-high: #e6e8eb;
    --cd-surface-container-highest: #e0e3e6;
    --cd-outline-variant: #c2c6d4;
    --cd-secondary-container: #c7e3ff;
    --cd-tertiary-container: #006a71;
    --cd-primary-fixed: #d3e4ff;
    --cd-sidebar-bg: #f8fafc;
    --cd-sidebar-border: #e2e8f0;
    --cd-nav-active: #1d4ed8;
    --cd-shadow: 0 1px 3px rgba(0, 73, 131, 0.08);
    --cd-sidebar-width: 256px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--cd-on-surface);
}

h1, h2, h3, h4, h5, .welcome-title, .sidebar-title, .filter-title, .card-title {
    font-family: 'Manrope', 'Inter', sans-serif;
}

.logo {
    max-width: 250px;
    height: auto;
}

.card {
    border-radius: 12px;
    box-shadow: var(--cd-shadow);
    border-color: rgba(194, 198, 212, 0.25);
}

.btn {
    padding: 12px 20px;
    border-radius: 8px;
}

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

.btn-primary:hover {
    background-color: var(--cd-primary-container);
    border-color: var(--cd-primary-container);
}

.btn-outline-primary {
    color: var(--cd-primary);
    border-color: var(--cd-primary);
}

.btn-outline-primary:hover {
    background-color: var(--cd-primary);
    border-color: var(--cd-primary);
    color: var(--cd-on-primary);
}

.form-control {
    padding: 12px;
    border-radius: 8px;
}

.table th {
    background-color: var(--cd-surface-container-low);
}

.action-buttons .btn {
    margin: 0 2px;
    padding: 8px 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container-fluid {
        padding: 0 15px;
    }
    
    .navbar-brand img {
        height: 30px;
    }
    
    .card {
        margin-bottom: 15px;
        border-radius: 12px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-group {
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .btn-group .btn {
        font-size: 12px;
        padding: 8px 12px;
        margin-bottom: 5px;
    }
    
    .table-responsive {
        font-size: 14px;
        border-radius: 8px;
        overflow: hidden;
    }
    
    .table {
        margin-bottom: 0;
    }
    
    .table th,
    .table td {
        padding: 12px 8px;
        vertical-align: middle;
        border-bottom: 1px solid #dee2e6;
    }
    
    .table tbody tr:hover {
        background-color: #f8f9fa;
    }
    
    .action-buttons .d-flex {
        min-width: 120px;
    }
    
    .action-buttons .btn {
        font-size: 12px;
        padding: 8px 12px;
        min-width: 40px;
        border-radius: 6px;
    }
    
    .form-control-sm {
        font-size: 14px;
        padding: 8px 12px;
        border-radius: 8px;
    }
    
    .form-label.small {
        font-size: 12px;
        font-weight: 600;
        color: #6c757d;
        margin-bottom: 4px;
    }
    
    .fw-bold {
        font-size: 14px;
        color: #212529;
    }
    
    .text-muted small {
        font-size: 12px;
        line-height: 1.2;
    }
}

@media (max-width: 576px) {
    .container-fluid {
        padding: 0 10px;
    }
    
    .navbar-brand {
        font-size: 16px;
    }
    
    .navbar-nav {
        text-align: center;
    }
    
    .navbar-nav .nav-link {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .card-body {
        padding: 12px;
    }
    
    .card-title {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .table {
        font-size: 13px;
    }
    
    .table th,
    .table td {
        padding: 10px 6px;
    }
    
    .btn-group {
        justify-content: center;
    }
    
    .btn-group .btn {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .action-buttons .btn {
        font-size: 11px;
        padding: 6px 10px;
        min-width: 36px;
    }
    
    .form-control-sm {
        font-size: 13px;
        padding: 6px 10px;
    }
    
    .fw-bold {
        font-size: 13px;
    }
    
    .text-muted small {
        font-size: 11px;
    }
    
    .d-flex.gap-1 {
         gap: 0.25rem !important;
     }
 }

/* Layout Container */
.layout-container {
    display: block;
    min-height: 100vh;
}

/* Sidebar Styles (diseño clínico claro) */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--cd-sidebar-width);
    background: var(--cd-sidebar-bg);
    color: var(--cd-on-surface);
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
    box-shadow: none;
    border-right: 1px solid var(--cd-sidebar-border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    order: 1;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: none;
    text-align: left;
}

.sidebar-logo {
    height: 36px;
    margin-bottom: 0.5rem;
    filter: none;
}

.sidebar-title {
    color: #1e3a8a;
    font-weight: 800;
    margin: 0;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}

.sidebar-subtitle {
    color: #64748b;
    font-weight: 600;
    margin: 0;
    font-size: 0.625rem;
    margin-top: 0.125rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.sidebar-user {
    order: 3;
    margin-top: auto;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--cd-sidebar-border);
    border-bottom: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    font-size: 1.35rem;
    color: var(--cd-primary);
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cd-primary-fixed);
    border-radius: 50%;
    border: 2px solid var(--cd-primary-fixed);
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 700;
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
    color: #1e3a8a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.625rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    order: 2;
    flex: 1;
    padding: 0.35rem 0 1rem;
}

.sidebar-nav .nav {
    padding: 0;
}

.sidebar-nav .nav-item {
    margin-bottom: 0.25rem;
    display: none; /* Oculto por defecto hasta que se verifiquen permisos */
}

/* Mostrar elementos cuando se verifiquen los permisos */
.sidebar-nav .nav-item.sidebar-item-visible {
    display: block !important;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.25rem;
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s ease, background 0.2s ease;
    border-radius: 0;
    position: relative;
}

.sidebar-nav .nav-link:hover {
    background: rgba(0, 73, 131, 0.06);
    color: #1e3a8a;
    transform: none;
}

.sidebar-nav .nav-link.active {
    background: #ffffff;
    color: var(--cd-nav-active);
    border-right: 4px solid var(--cd-nav-active);
    font-weight: 700;
    box-shadow: inset 0 1px 0 rgba(0, 0, 0, 0.03);
}

.sidebar-nav .nav-link i {
    font-size: 1.05rem;
    margin-right: 0.75rem;
    width: 22px;
    text-align: center;
    color: inherit;
}

.sidebar-nav .nav-link span {
    font-weight: 600;
    font-size: 0.875rem;
    letter-spacing: -0.01em;
}

.sidebar-footer {
    order: 4;
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid var(--cd-sidebar-border);
    margin-top: 0;
}

.sidebar-footer .btn {
    border-color: var(--cd-outline-variant);
    color: var(--cd-primary);
    background: #ffffff;
    transition: all 0.2s ease;
}

.sidebar-footer .btn:hover {
    background: var(--cd-surface-container-low);
    border-color: var(--cd-primary);
    color: var(--cd-primary);
}

/* Mobile Header */
.mobile-header {
    background: white;
    border-bottom: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 999;
}

.mobile-header .btn-link {
    color: var(--cd-primary);
    text-decoration: none;
    padding: 0.5rem;
}

.mobile-header .btn-link:hover {
    color: var(--cd-primary-container);
}

/* Barra superior tipo portal clínico */
.clinical-app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.65rem 2rem;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.7);
    box-shadow: 0 1px 2px rgba(0, 73, 131, 0.04);
}

.clinical-app-header-title {
    font-family: 'Manrope', sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    color: #1e3a8a;
    margin: 0;
    flex-shrink: 0;
}

.clinical-app-header-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 28rem;
}

.clinical-app-header-search-wrap .clinical-search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.85rem;
    pointer-events: none;
}

.clinical-app-header-search {
    width: 100%;
    border: none;
    background: var(--cd-surface-container-low);
    border-radius: 0.5rem;
    padding: 0.45rem 0.75rem 0.45rem 2.35rem;
    font-size: 0.875rem;
    font-family: 'Manrope', 'Inter', sans-serif;
    color: var(--cd-on-surface);
}

.clinical-app-header-search:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 73, 131, 0.15);
}

.clinical-app-header-search::placeholder {
    color: #94a3b8;
}

.clinical-app-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.clinical-app-header-actions .btn-link {
    color: #64748b;
    padding: 0.35rem 0.5rem;
    border-radius: 999px;
    text-decoration: none;
}

.clinical-app-header-actions .btn-link:hover {
    color: var(--cd-primary);
    background: rgba(0, 73, 131, 0.06);
}

.clinical-header-user-line {
    text-align: right;
}

.clinical-header-user-line .clinical-header-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #1e3a8a;
    margin: 0;
    line-height: 1.2;
}

.clinical-header-user-line .clinical-header-role {
    font-size: 0.625rem;
    color: #64748b;
    margin: 0;
    line-height: 1.2;
}

.clinical-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 0.5rem;
    background: var(--cd-primary-fixed);
    color: var(--cd-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

@media (max-width: 575.98px) {
    .clinical-app-header {
        padding: 0.5rem 1rem;
    }
    .clinical-header-user-line {
        display: none;
    }
}

/* Main Content */
.main-content {
    min-height: 100vh;
    background: var(--cd-background);
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Default state - sidebar visible */
.layout-container:not(.sidebar-hidden) .main-content {
    margin-left: var(--cd-sidebar-width);
    width: calc(100% - var(--cd-sidebar-width));
}

/* Sidebar Toggle Buttons */
.sidebar-toggle-show {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.sidebar-toggle-show:hover {
    background: #f8f9fa;
    transform: scale(1.05);
}

.sidebar-header .btn-link {
    color: #64748b;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sidebar-header .btn-link:hover {
    color: var(--cd-primary);
    background: rgba(0, 73, 131, 0.06);
}

/* Botones del encabezado del sidebar heredan tema claro (quitar utilidad Bootstrap text-white heredada) */
.sidebar-header .btn-link.text-white {
    color: #64748b !important;
}

.sidebar-header .btn-link.text-white:hover {
    color: var(--cd-primary) !important;
}

/* Sidebar Hidden State */
.layout-container.sidebar-hidden .sidebar {
    transform: translateX(-100%);
}

.layout-container.sidebar-hidden .main-content {
    margin-left: 0;
    width: 100%;
}

/* Desktop behavior - ensure proper spacing */
@media (min-width: 992px) {
    .layout-container:not(.sidebar-hidden) .main-content {
        margin-left: var(--cd-sidebar-width) !important;
        width: calc(100% - var(--cd-sidebar-width)) !important;
    }
    
    .layout-container.sidebar-hidden .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Smooth transition for content when sidebar toggles */
    .layout-container .main-content .container-fluid {
        transition: all 0.3s ease;
        max-width: 100%;
    }
    
    /* Ensure cards and content adapt smoothly */
    .layout-container .main-content .card,
    .layout-container .main-content .row {
        transition: all 0.3s ease;
    }
}

/* CSS específico para el nuevo layout del editor */
.editor-content-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 1rem;
    transition: all 0.3s ease;
}

.editor-section {
    width: 100%;
    max-width: 100%;
    transition: all 0.3s ease;
}

/* Asegurar que las cards dentro de las secciones se adapten */
.editor-section .card {
    width: 100%;
    max-width: 100%;
    transition: all 0.3s ease;
}

/* Contenedor para las secciones de audio y dictado lado a lado */
.audio-speech-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.audio-recording-section,
.speech-recognition-section {
    flex: 1;
    min-width: 300px;
}

/* Responsive para pantallas pequeñas */
@media (max-width: 768px) {
    .audio-speech-container {
        flex-direction: column;
    }
    
    .audio-recording-section,
    .speech-recognition-section {
        flex: none;
        min-width: auto;
    }
}

/* Sync Adjustment Controls */
.sync-adjustment-panel {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.sync-adjustment-panel .card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.sync-adjustment-panel .card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
}

.sync-adjustment-panel .form-range {
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
}

.sync-adjustment-panel .form-range::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    background: #007bff;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}

.sync-adjustment-panel .form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #007bff;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}

.sync-adjustment-panel .btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.sync-adjustment-panel .btn-sm:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Responsive adjustments for sync controls */
@media (max-width: 768px) {
    .sync-adjustment-panel .col-md-6 {
        margin-bottom: 1rem;
    }
    
    .sync-adjustment-panel .d-flex.gap-2 {
        flex-direction: column;
        gap: 0.5rem !important;
    }
    
    .sync-adjustment-panel .btn-sm {
        width: 100%;
    }
}

/* Smooth transitions for content adaptation */
.main-content .container-fluid,
.main-content .card,
.main-content .row {
    transition: width 0.3s ease, margin 0.3s ease;
}

.main-content .container-fluid {
    max-width: 100%;
}

.layout-container.sidebar-hidden .sidebar-toggle-show {
    display: flex !important;
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Mobile Responsive */
@media (max-width: 991.98px) {
    .layout-container {
        display: block;
    }
    
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    /* En móvil, siempre sin margen independientemente del estado del sidebar */
    .layout-container.sidebar-hidden .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .sidebar-user {
        display: none !important;
    }
    
    .sidebar-footer {
        display: none !important;
    }
}

@media (max-width: 576px) {
    .sidebar {
        width: 260px;
    }
    
    .sidebar-nav .nav-link {
        padding: 0.75rem 1rem;
    }
    
    .sidebar-nav .nav-link i {
        margin-right: 0.5rem;
    }
    
    .sidebar-header {
         padding: 1rem;
     }
 }



.dropdown-menu {
    border: none;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-radius: 10px;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
}

.dropdown-header {
    color: var(--cd-primary);
    font-weight: 600;
    padding: 0.5rem 1rem;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: var(--cd-surface-container-low);
    color: var(--cd-primary);
}

.dropdown-item.text-danger:hover {
    background: #f8d7da;
    color: #dc3545;
}

/* Welcome / estadísticas (estilo portal clínico) */
.welcome-card {
    background: transparent;
    color: inherit;
    padding: 0;
    border-radius: 0;
    margin-bottom: 1.75rem;
    box-shadow: none;
}

.welcome-card .row.align-items-center {
    align-items: stretch !important;
}

.welcome-title {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
    letter-spacing: -0.03em;
    color: var(--cd-primary);
}

.welcome-subtitle {
    font-size: 1rem;
    margin-bottom: 0;
    font-weight: 500;
    color: var(--cd-on-surface-variant);
}

.welcome-stats {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.stat-item {
    text-align: left;
    flex: 1;
    min-width: 8rem;
    max-width: 11rem;
    background: #ffffff;
    border: 1px solid rgba(194, 198, 212, 0.35);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--cd-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.welcome-stats .stat-item:last-child {
    background: linear-gradient(135deg, var(--cd-primary) 0%, var(--cd-primary-container) 100%);
    border: none;
    color: #ffffff;
}

.welcome-stats .stat-item:last-child .stat-number {
    color: #ffffff;
}

.welcome-stats .stat-item:last-child .stat-label {
    color: rgba(255, 255, 255, 0.75);
}

.stat-number {
    display: block;
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.35rem;
    color: var(--cd-primary);
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #64748b;
}

/* Estilos para el banner de información del estudio */
.study-info-banner {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.study-info-item {
    padding: 0.5rem 0;
}

.study-info-item small {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.study-info-item strong {
    font-size: 0.95rem;
    color: #fff;
    display: block;
    margin-top: 0.25rem;
    font-weight: 600;
}

.study-info-item .badge {
    font-size: 0.85rem;
    padding: 0.35rem 0.65rem;
    margin-top: 0.25rem;
}

/* Responsive para el banner de información del estudio */
@media (max-width: 991.98px) {
    .study-info-banner {
        padding: 0.75rem;
    }
    
    .study-info-item {
        padding: 0.4rem 0;
    }
    
    .study-info-item strong {
        font-size: 0.9rem;
    }
}

/* Search Filters */
.search-filters {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(194, 198, 212, 0.2);
    box-shadow: var(--cd-shadow);
}

.filter-title {
    color: var(--cd-on-surface-variant);
    font-weight: 700;
    font-size: 0.7rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.search-filters .form-control,
.search-filters .form-select {
    background: var(--cd-surface-container-low);
    border: none;
    border-radius: 0.5rem;
}

.search-filters .form-control:focus,
.search-filters .form-select:focus {
    box-shadow: 0 0 0 2px rgba(0, 73, 131, 0.15);
}

.btn-search {
    background: linear-gradient(90deg, var(--cd-primary), var(--cd-primary-container));
    border: none;
    color: white;
    font-weight: 700;
    padding: 0.65rem 1.25rem;
    border-radius: 0.5rem;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 73, 131, 0.12);
}

.btn-search:hover {
    background: linear-gradient(90deg, var(--cd-primary-container), var(--cd-primary));
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 73, 131, 0.18);
}

/* Filter Card */
.filter-card .card-header {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.filter-card .card-title {
    color: var(--cd-primary);
    font-weight: 700;
}

.layout-container .main-content .card {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid rgba(194, 198, 212, 0.2);
    box-shadow: var(--cd-shadow);
}

.layout-container .main-content .card-header {
    background: #ffffff;
    border-bottom: 1px solid rgba(194, 198, 212, 0.25);
}

.layout-container .main-content .card-header .card-title {
    color: #1e3a8a;
    font-weight: 700;
}





@media (min-width: 769px) and (max-width: 1024px) {
    /* Tablet styles */
    .container {
        max-width: 95%;
    }
    
    .table {
        font-size: 15px;
    }
    
    .btn-group .btn {
        font-size: 14px;
        padding: 10px 15px;
    }
    
    .action-buttons .btn {
        padding: 8px 10px;
        margin: 0 3px;
    }
}

/* Modality Filters */
.modality-filters {
    margin-bottom: 1.5rem;
}

.modality-btn {
    background: white;
    border: 2px solid #e9ecef;
    color: #6c757d;
    padding: 0.5rem 1.2rem;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    min-width: 60px;
}

.modality-btn:hover {
    border-color: var(--cd-primary);
    color: var(--cd-primary);
    background: var(--cd-surface-container-low);
    transform: translateY(-1px);
}

.modality-btn.active {
    background: var(--cd-primary);
    border-color: var(--cd-primary);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 73, 131, 0.2);
}

.modality-btn.active:hover {
    background: var(--cd-primary-container);
    border-color: var(--cd-primary-container);
    color: white;
}

/* Studies Table */
.studies-table {
    background: white;
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: none;
    border: none;
}

.studies-table thead {
    background: var(--cd-surface-container-low);
}

.studies-table th {
    background: var(--cd-surface-container-low);
    border-bottom: 1px solid rgba(194, 198, 212, 0.35);
    font-weight: 700;
    color: #64748b;
    padding: 1rem 1.25rem;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.studies-table td {
    padding: 1.15rem 1.25rem;
    vertical-align: middle;
    border-bottom: 1px solid rgba(194, 198, 212, 0.12);
    font-size: 0.875rem;
}

.studies-table tbody tr:hover {
    background-color: rgba(199, 227, 255, 0.35);
    transition: background-color 0.2s ease;
}

/* Modality Badges */
.modality-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: #495057 !important; /* Color más oscuro para mejor legibilidad */
}

.modality-rx {
    background: #e3f2fd;
    color: #1976d2 !important;
}

.modality-tc {
    background: #fff3e0;
    color: #f57c00 !important;
}

/* Status Badges */
.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-completed {
    background: #e8f5e8;
    color: #2e7d32;
}

.status-processing {
    background: #fff3e0;
    color: #f57c00;
}

/* Action Buttons */
.btn-action {
    border: 1px solid #e9ecef;
    background: white;
    color: #6c757d;
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.btn-info:hover {
    background: #0dcaf0;
    border-color: #0dcaf0;
    color: white;
}

.btn-view:hover {
    background: var(--cd-primary);
    border-color: var(--cd-primary);
    color: white;
}

.btn-download:hover {
    background: #6c757d;
    border-color: #6c757d;
    color: white;
}

/* Responsive adjustments for User Management table */
@media (max-width: 991.98px) {
    /* Mejorar tabla de usuarios en pantallas medianas */
    #usersTableBody th,
    #usersTableBody td {
        font-size: 0.875rem;
        padding: 0.5rem;
    }
}

/* Responsive adjustments for Editor */
.editor-content-wrapper {
    padding: 1.5rem;
    transition: all 0.3s ease;
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    /* Reducir padding en pantallas lg medianas */
    .editor-content-wrapper {
        padding: 1rem;
    }
    
    .main-content {
        max-width: calc(100vw - var(--cd-sidebar-width) - 2rem);
    }
}

@media (min-width: 1200px) {
    /* Padding normal en pantallas xl+ */
    .editor-content-wrapper {
        padding: 2rem;
    }
}

/* Optimizar secciones de audio en editor para pantallas medianas */
@media (max-width: 991.98px) {
    .audio-speech-container {
        flex-direction: column;
    }
    
    .audio-recording-section,
    .speech-recognition-section {
        flex: none;
        min-width: auto;
        width: 100%;
    }
}

/* Asegurar que col-md-6 se apile en pantallas medianas */
@media (max-width: 991.98px) {
    .editor-section .col-md-6,
    .editor-section .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Responsive adjustments for Estudios Manager action buttons */
@media (max-width: 991.98px) {
    /* Mejorar espaciado de botones de acción en pantallas medianas */
    .studies-table .btn-group,
    .studies-table .d-flex.gap-1 {
        flex-wrap: wrap;
        gap: 0.25rem !important;
    }
    
    /* Reducir tamaño de botones en pantallas medianas */
    .studies-table .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Asegurar que los botones de acciones masivas se adapten */
    #bulkActions {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    #bulkActions .btn {
        flex: 1 1 auto;
        min-width: 120px;
    }
}

@media (min-width: 992px) {
    /* En pantallas grandes, mantener espaciado normal */
    .studies-table .d-flex.gap-1 {
        gap: 0.5rem;
    }
}

/* Responsive adjustments for Informes Manager table */
@media (max-width: 991.98px) {
    /* Reducir ancho mínimo de columna Acciones en pantallas medianas */
    #reportsTable th[style*="min-width: 250px"],
    #reportsTable td:nth-last-child(1) {
        min-width: 180px !important;
    }
    
    /* Ajustar tamaño del toggle PACS en pantallas medianas */
    .pacs-format-toggle-container {
        margin-left: 5px !important;
    }
    
    .pacs-format-toggle {
        transform: scale(0.85);
    }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    /* Ajuste intermedio para pantallas lg */
    #reportsTable th[style*="min-width: 250px"],
    #reportsTable td:nth-last-child(1) {
        min-width: 220px !important;
    }
}

/* Utility classes for responsive behavior */
.text-truncate-mobile {
    @media (max-width: 768px) {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }
}

.hide-mobile {
    @media (max-width: 576px) {
        display: none !important;
    }
}

.show-mobile {
    display: none;
    @media (max-width: 576px) {
        display: block !important;
    }
}

/* Estilos para modal en pantalla completa */
.modal-fullscreen .modal-dialog {
    width: 100vw;
    max-width: none;
    height: 100vh;
    margin: 0;
    padding: 0;
}

.modal-fullscreen .modal-content {
    height: 100vh;
    border: 0;
    border-radius: 0;
}

.modal-fullscreen .modal-body {
    overflow-y: auto;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

/* Asegurar que TinyMCE ocupe el espacio disponible en pantalla completa */
.modal-fullscreen #reportContent {
    min-height: calc(100vh - 400px);
}

.modal-fullscreen .tox-tinymce {
    min-height: calc(100vh - 400px) !important;
}