/**
 * VeriFactu-Pro - Estilos Custom
 * Enterprise-grade: Variables CSS, diseño coherente
 */

/* ==================== VARIABLES CSS ==================== */
:root {
    /* Colores primarios */
    --vf-primary: #0d6efd;
    --vf-secondary: #6c757d;
    --vf-success: #198754;
    --vf-danger: #dc3545;
    --vf-warning: #ffc107;
    --vf-info: #0dcaf0;

    /* Colores de estado AEAT */
    --vf-aeat-pending: #ffc107;
    --vf-aeat-sent: #0dcaf0;
    --vf-aeat-accepted: #198754;
    --vf-aeat-rejected: #dc3545;

    /* Espaciado */
    --vf-spacing-xs: 0.25rem;
    --vf-spacing-sm: 0.5rem;
    --vf-spacing-md: 1rem;
    --vf-spacing-lg: 1.5rem;
    --vf-spacing-xl: 2rem;

    /* Tipografía */
    --vf-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --vf-font-size-sm: 0.75rem;
    --vf-font-size-base: 0.875rem;
    --vf-font-size-lg: 1rem;

    /* Sombras */
    --vf-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --vf-shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --vf-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);

    /* Border radius */
    --vf-radius-sm: 0.25rem;
    --vf-radius-md: 0.375rem;
    --vf-radius-lg: 0.5rem;
}

/* ==================== LAYOUT ==================== */
body {
    font-family: var(--vf-font-family);
    font-size: var(--vf-font-size-base);
    background-color: #f8f9fa;
}

/* ==================== SIDEBAR - ENTERPRISE GRADE UX ==================== */
/* Base Structure */
.sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 200px;
    background: #F9FAFB;
    z-index: 99;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    border-right: 1px solid #E5E7EB;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
}

/* Sidebar Header: Environment Badge */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    background: #FFFFFF;
    border-bottom: 1px solid #E5E7EB;
    flex-shrink: 0;
}

.environment-badge {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #374151;
}

.env-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: pulse-env 2s ease-in-out infinite;
}

.env-production {
    background: #10B981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.env-staging {
    background: #F59E0B;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

.env-development {
    background: #3B82F6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

@keyframes pulse-env {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #FFFFFF;
    border: 1px solid #E5E7EB;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #6B7280;
    font-size: 14px;
}

.sidebar-toggle-btn:hover {
    background: #F3F4F6;
    border-color: #0078D4;
    color: #0078D4;
}

.sidebar-content {
    padding: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.enterprise-sidebar {
    background: #F9FAFB;
}

/* Navigation Items - Perfect Alignment */
.sidebar .nav-item {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.7rem;
    color: #495057;
    font-size: 0.7rem;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    gap: 0;
}

.sidebar .nav-link i {
    font-size: 0.875rem;
    width: 16px;
    flex-shrink: 0;
    margin-right: 0.5rem;
    transition: color 0.2s ease;
}

.sidebar .nav-text {
    flex: 0 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease;
}

.sidebar .nav-link:hover {
    background: #FFFFFF;
    color: #0078D4;
    border-left-color: #93C5FD;
    transform: translateX(2px);
}

.sidebar .nav-link.active {
    background: #E8F1FF;
    border-left-color: #2563EB;
    color: #1E40AF;
    font-weight: 600;
}

.sidebar .nav-link.active i {
    color: #2563EB;
}

/* Badges and Counts - Perfect Spacing */
.nav-badge,
.nav-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.55rem;
    font-weight: 600;
    line-height: 1;
    padding: 0.15rem 0.3rem;
    border-radius: 8px;
    margin-left: auto;
    transition: all 0.2s ease;
}

.nav-badge {
    color: #fff;
}

.nav-count {
    background: #E9ECEF;
    color: #6C757D;
}

/* Section Headers - Enhanced Hierarchy */
.sidebar .nav-section {
    display: flex;
    align-items: center;
    padding: 0.65rem 0.75rem 0.4rem;
    margin-top: 0.6rem;
    pointer-events: none;
    background: rgba(0, 120, 212, 0.03);
    border-left: 3px solid #0078D4;
}

.sidebar .nav-section:first-child {
    margin-top: 0.4rem;
}

.section-icon {
    font-size: 0.65rem;
    color: #0078D4;
    opacity: 0.8;
    width: 14px;
    flex-shrink: 0;
    margin-right: 0.4rem;
}

.sidebar .nav-text-small {
    font-size: 0.55rem;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    line-height: 1;
}

/* Dividers - Clean Separation */
.sidebar-divider {
    border: 0;
    border-top: 1px solid #E5E7EB;
    margin: 0.6rem 0;
    opacity: 1;
}

/* Sidebar Footer - Status & Version */
.sidebar-footer {
    flex-shrink: 0;
    padding: 0.75rem;
    background: #FFFFFF;
    border-top: 1px solid #E5E7EB;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: opacity 0.2s ease;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.6rem;
    font-weight: 500;
    color: #6B7280;
}

.status-indicator {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.status-connected {
    background: #10B981;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.status-disconnected {
    background: #EF4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.app-version {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.55rem;
    font-weight: 600;
    color: #9CA3AF;
}

.app-version i {
    font-size: 0.65rem;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #DEE2E6;
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: #ADB5BD;
}

/* Collapsed State - With Tooltips */
.sidebar.collapsed {
    width: 56px;
}

.sidebar.collapsed .env-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .nav-text-small,
.sidebar.collapsed .section-icon,
.sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-count,
.sidebar.collapsed .status-text,
.sidebar.collapsed .app-version span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .nav-link {
    justify-content: center;
    padding: 0.4rem;
}

.sidebar.collapsed .nav-link i {
    margin-right: 0;
}

.sidebar.collapsed .environment-badge {
    justify-content: center;
}

.sidebar.collapsed .sidebar-footer {
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.6rem 0.4rem;
}

.sidebar.collapsed .connection-status,
.sidebar.collapsed .app-version {
    justify-content: center;
}

/* Tooltips on Collapsed State */
.sidebar.collapsed .nav-link:hover::before {
    content: attr(title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #1F2937;
    color: #FFFFFF;
    padding: 0.4rem 0.6rem;
    border-radius: 5px;
    white-space: nowrap;
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 0.6rem;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar.collapsed .nav-link:hover::after {
    content: '';
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0.2rem;
    border: 5px solid transparent;
    border-right-color: #1F2937;
    z-index: 999;
}

/* ==================== GESTORÍA SECTION - GREEN THEME ==================== */
/* Gestoría-specific styling with emerald green color scheme */
:root {
    --vf-gestoria-primary: #10B981;      /* Emerald 500 */
    --vf-gestoria-hover: #D1FAE5;        /* Emerald 100 */
    --vf-gestoria-active: #059669;       /* Emerald 600 */
    --vf-gestoria-dark: #047857;         /* Emerald 700 */
    --vf-gestoria-light: #ECFDF5;        /* Emerald 50 */
}

/* Section headers with green accent */
.gestoria-section .nav-section {
    background: rgba(16, 185, 129, 0.05);
    border-left-color: var(--vf-gestoria-primary);
}

.gestoria-section .section-icon {
    color: var(--vf-gestoria-primary);
}

/* Navigation items - Green theme */
.gestoria-section .nav-link {
    color: #374151;
}

.gestoria-section .nav-link:hover {
    background: var(--vf-gestoria-hover);
    color: var(--vf-gestoria-active);
    border-left-color: var(--vf-gestoria-primary);
}

.gestoria-section .nav-link:hover i {
    color: var(--vf-gestoria-active);
}

.gestoria-section .nav-link.active {
    background: linear-gradient(135deg, var(--vf-gestoria-primary) 0%, var(--vf-gestoria-active) 100%);
    border-left-color: var(--vf-gestoria-dark);
    color: #FFFFFF;
    font-weight: 600;
}

.gestoria-section .nav-link.active i {
    color: #FFFFFF;
}

/* Badges with green theme */
.gestoria-section .nav-badge.bg-success {
    background: var(--vf-gestoria-primary) !important;
}

.gestoria-section .nav-badge.bg-warning {
    background: #F59E0B !important;
}

.gestoria-section .nav-badge.bg-danger {
    background: #EF4444 !important;
}

.gestoria-section .nav-badge.bg-info {
    background: #06B6D4 !important;
}

/* Gestoria count badges with subtle green */
.gestoria-section .nav-count {
    background: var(--vf-gestoria-light);
    color: var(--vf-gestoria-dark);
    font-weight: 600;
}

/* Responsive */
@media (max-width: 1200px) {
    .sidebar {
        width: 56px;
    }

    .sidebar:hover {
        width: 200px;
    }
}

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

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    .sidebar-footer {
        position: static;
    }
}

/* Main content */
main {
    margin-left: 200px;
    padding-top: 3rem;
    transition: margin-left 0.3s ease;
}

main.expanded {
    margin-left: 56px;
}

/* Auto-collapse en pantallas medianas */
@media (max-width: 1200px) {
    .sidebar {
        width: 56px;
    }

    .sidebar .nav-text,
    .sidebar .nav-text-small {
        opacity: 0;
        width: 0;
        overflow: hidden;
    }

    main {
        margin-left: 60px;
    }

    /* Expandir al hover en desktop */
    .sidebar:hover {
        width: 250px;
    }

    .sidebar:hover .nav-text,
    .sidebar:hover .nav-text-small {
        opacity: 1;
        width: auto;
    }
}

/* Mobile responsive */
@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: 250px;
    }

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

    main {
        margin-left: 0 !important;
    }
}

/* ==================== COMPONENTES ==================== */

/* PDF Viewer Container */
.pdf-viewer-container {
    position: relative;
    border: 1px solid #dee2e6;
    border-radius: var(--vf-radius-md);
    overflow: auto;
    background-color: #525659;
    max-height: 80vh;
}

.pdf-viewer-container canvas {
    display: block;
    margin: 0 auto;
}

#overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: auto;
    cursor: crosshair;
}

/* Field Cards (plantillas) */
.field-card {
    transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

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

/* Estado AEAT badges */
.badge-aeat-pending {
    background-color: var(--vf-aeat-pending);
    color: #000;
}

.badge-aeat-sent {
    background-color: var(--vf-aeat-sent);
    color: #000;
}

.badge-aeat-accepted {
    background-color: var(--vf-aeat-accepted);
    color: #fff;
}

.badge-aeat-rejected {
    background-color: var(--vf-aeat-rejected);
    color: #fff;
}

/* Dropzone custom */
.dropzone {
    border: 2px dashed var(--vf-primary);
    border-radius: var(--vf-radius-lg);
    background-color: rgba(13, 110, 253, 0.05);
    transition: all 0.3s ease;
    padding: 2rem;
    text-align: center;
}

.dropzone:hover {
    border-color: var(--vf-primary);
    background-color: rgba(13, 110, 253, 0.1);
}

.dropzone.dz-drag-hover {
    border-color: var(--vf-success);
    background-color: rgba(25, 135, 84, 0.1);
}

/* Toast container (notificaciones) */
#toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 9999;
}

/* Loading spinner HTMX */
.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-indicator {
    display: none;
}

.htmx-loading {
    opacity: 0.6;
    cursor: wait;
}

/* ==================== UTILITIES ==================== */

/* Text utilities */
.text-xs { font-size: var(--vf-font-size-sm); }
.text-lg { font-size: var(--vf-font-size-lg); }

/* Spacing utilities */
.gap-xs { gap: var(--vf-spacing-xs); }
.gap-sm { gap: var(--vf-spacing-sm); }
.gap-md { gap: var(--vf-spacing-md); }
.gap-lg { gap: var(--vf-spacing-lg); }

/* Shadow utilities */
.shadow-custom-sm { box-shadow: var(--vf-shadow-sm); }
.shadow-custom-md { box-shadow: var(--vf-shadow-md); }
.shadow-custom-lg { box-shadow: var(--vf-shadow-lg); }

/* ==================== RESPONSIVE ==================== */

/* Global compact mode - optimized for 100% zoom */
body {
    font-size: 0.875rem;
}

.text-xs {
    font-size: 0.7rem !important;
}

.h1 { font-size: 2rem !important; }
.h2 { font-size: 1.75rem !important; }
.h3 { font-size: 1.5rem !important; }
.h4 { font-size: 1.25rem !important; }
.h5 { font-size: 1.1rem !important; }
.h6 { font-size: 0.95rem !important; }

.card {
    margin-bottom: 1rem;
}

.card-body {
    padding: 1rem !important;
}

.card-title {
    font-size: 1rem !important;
    margin-bottom: 0.75rem !important;
}

.card-header {
    padding: 0.75rem 1rem !important;
    font-size: 0.95rem !important;
}

.btn {
    font-size: 0.875rem !important;
    padding: 0.4rem 0.75rem !important;
}

.btn-sm {
    font-size: 0.75rem !important;
    padding: 0.3rem 0.6rem !important;
}

.btn-lg {
    font-size: 1rem !important;
    padding: 0.6rem 1rem !important;
}

.form-control {
    font-size: 0.875rem !important;
    padding: 0.4rem 0.75rem !important;
}

.form-control-sm {
    font-size: 0.75rem !important;
    padding: 0.3rem 0.6rem !important;
}

.form-label {
    font-size: 0.875rem !important;
    margin-bottom: 0.4rem !important;
}

.table {
    font-size: 0.85rem !important;
}

.table th,
.table td {
    padding: 0.6rem !important;
}

.modal-header {
    padding: 1rem !important;
}

.modal-body {
    padding: 1rem !important;
}

.modal-footer {
    padding: 0.75rem !important;
}

@media (max-width: 767.98px) {
    .sidebar {
        padding-top: 3rem;
    }

    main {
        padding-top: 3rem;
    }

    .pdf-viewer-container {
        max-height: 60vh;
    }
}

/* ==================== SCROLL TO TOP BUTTON (MOBILE) ==================== */
.scroll-to-top-mobile {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    z-index: var(--vf-mobile-z-tooltip, 1070);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.scroll-to-top-mobile:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.scroll-to-top-mobile:active {
    transform: translateY(-1px);
}

/* ==================== PRINT ==================== */
@media print {
    .sidebar,
    .navbar,
    .no-print {
        display: none !important;
    }

    main {
        padding: 0;
        margin: 0;
    }
}

/* ==================== ENTERPRISE RESPONSIVE - MOBILE FIRST ==================== */

/* ========================================================================
   MOBILE - Extra Small Devices (< 576px)
   ======================================================================== */
@media (max-width: 575.98px) {
    /* Container adjustments */
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Typography */
    body {
        font-size: 0.875rem;
    }

    .h1, h1 { font-size: 1.75rem !important; }
    .h2, h2 { font-size: 1.5rem !important; }
    .h3, h3 { font-size: 1.25rem !important; }
    .h4, h4 { font-size: 1.125rem !important; }
    .h5, h5 { font-size: 1rem !important; }
    .h6, h6 { font-size: 0.875rem !important; }

    /* Sidebar - Full overlay on mobile */
    .sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 280px;
        height: 100vh;
        z-index: 1040;
        transition: left 0.3s ease;
        padding-top: 56px;
    }

    .sidebar.show {
        left: 0;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    /* Sidebar backdrop */
    body::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1039;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    body.sidebar-open::after {
        opacity: 1;
        pointer-events: auto;
    }

    /* Main content - Full width on mobile */
    main {
        margin-left: 0 !important;
        padding-top: 56px;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    /* Cards - Full width stacking */
    .card {
        margin-bottom: 1rem;
        border-radius: 0.75rem;
    }

    .card-body {
        padding: 1rem !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
    }

    /* Buttons - Full width on mobile */
    .btn {
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
        min-height: 44px;
    }

    .btn-sm {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
        min-height: 38px;
    }

    .btn-block-mobile {
        display: block;
        width: 100%;
        margin-bottom: 0.5rem;
    }

    /* Forms - Touch friendly */
    .form-control {
        padding: 0.75rem 1rem !important;
        font-size: 1rem !important;
        min-height: 44px;
    }

    .form-control-sm {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
        min-height: 38px;
    }

    .form-label {
        font-size: 0.875rem !important;
        margin-bottom: 0.5rem !important;
    }

    /* Tables - Responsive cards */
    .table-responsive {
        border: none;
        box-shadow: none;
    }

    .table {
        font-size: 0.875rem !important;
    }

    /* Modal - Full screen on mobile */
    .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }

    .modal-content {
        height: 100%;
        border-radius: 0;
        border: none;
    }

    .modal-header {
        padding: 1rem !important;
        border-radius: 0;
    }

    .modal-body {
        padding: 1rem !important;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 1rem !important;
        flex-wrap: nowrap;
        border-radius: 0;
    }

    .modal-footer .btn {
        margin: 0 0.25rem;
    }

    /* Navbar - Mobile optimized */
    .navbar {
        height: 56px;
    }

    .navbar-container {
        padding: 0 0.75rem;
    }

    /* Hide desktop-only elements */
    .hide-mobile {
        display: none !important;
    }

    /* Spacing adjustments */
    .py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
    .py-5 { padding-top: 2rem !important; padding-bottom: 2rem !important; }
    .my-4 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }
    .my-5 { margin-top: 2rem !important; margin-bottom: 2rem !important; }

    /* Grid - Single column on mobile */
    .row > [class*="col-"] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Dropdowns - Full width on mobile */
    .dropdown-menu {
        width: 100%;
        min-width: 100%;
    }
}

/* ========================================================================
   MOBILE - Small Devices (576px - 767.98px)
   ======================================================================== */
@media (min-width: 576px) and (max-width: 767.98px) {
    .container {
        max-width: 540px;
    }

    /* Sidebar - Collapsed by default */
    .sidebar {
        width: 56px;
    }

    .sidebar:hover {
        width: 250px;
    }

    main {
        margin-left: 56px !important;
    }

    /* Cards - 2 columns */
    .card-deck > .card {
        flex: 0 0 calc(50% - 1rem);
    }
}

/* ========================================================================
   TABLET - Medium Devices (768px - 991.98px)
   ======================================================================== */
@media (min-width: 768px) and (max-width: 991.98px) {
    .container {
        max-width: 720px;
    }

    /* Sidebar - Collapsed by default on tablets */
    .sidebar {
        width: 56px;
    }

    .sidebar:hover {
        width: 250px;
    }

    main {
        margin-left: 56px !important;
        padding-top: 3.5rem;
    }

    /* Typography adjustments */
    body {
        font-size: 0.875rem;
    }

    /* Cards - 2-3 columns */
    .card-deck > .card {
        flex: 0 0 calc(50% - 1rem);
    }

    /* Tables - Smaller font */
    .table {
        font-size: 0.85rem !important;
    }

    .table th,
    .table td {
        padding: 0.5rem !important;
    }
}

/* ========================================================================
   DESKTOP - Large Devices (992px - 1199.98px)
   ======================================================================== */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .container {
        max-width: 960px;
    }

    /* Sidebar - Auto-collapse on medium desktops */
    .sidebar {
        width: 56px;
    }

    .sidebar:hover {
        width: 250px;
    }

    main {
        margin-left: 56px !important;
    }

    /* Cards - 3 columns */
    .card-deck > .card {
        flex: 0 0 calc(33.333% - 1rem);
    }
}

/* ========================================================================
   DESKTOP - Extra Large Devices (1200px - 1399.98px)
   ======================================================================== */
@media (min-width: 1200px) and (max-width: 1399.98px) {
    .container {
        max-width: 1140px;
    }

    /* Sidebar - Full width */
    .sidebar {
        width: 200px;
    }

    main {
        margin-left: 200px !important;
    }

    /* Cards - 4 columns */
    .card-deck > .card {
        flex: 0 0 calc(25% - 1rem);
    }
}

/* ========================================================================
   DESKTOP - XXL Devices (>= 1400px)
   ======================================================================== */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }

    /* Sidebar - Full width */
    .sidebar {
        width: 250px;
    }

    main {
        margin-left: 250px !important;
    }

    /* Cards - 4-5 columns */
    .card-deck > .card {
        flex: 0 0 calc(20% - 1rem);
    }

    /* More comfortable spacing */
    .container-fluid {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* ========================================================================
   LANDSCAPE ORIENTATION - Mobile Devices
   ======================================================================== */
@media (max-width: 767.98px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .modal-dialog {
        max-height: 100vh;
        margin: 0;
    }

    .modal-body {
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }

    /* Compact navbar in landscape */
    .navbar {
        height: 48px;
    }

    main {
        padding-top: 48px;
    }
}

/* ========================================================================
   TOUCH DEVICES - Enhanced Interactions
   ======================================================================== */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .card:hover {
        transform: none;
        box-shadow: var(--vf-shadow-sm);
    }

    .btn:hover {
        transform: none;
    }

    /* Larger tap targets */
    .btn,
    .form-control,
    .nav-link,
    a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Active state feedback */
    .btn:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }

    .nav-link:active {
        background-color: rgba(0, 0, 0, 0.05);
    }
}

/* ========================================================================
   HIGH DPI SCREENS - Retina Display Optimization
   ======================================================================== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Sharper borders */
    .card,
    .modal-content,
    .dropdown-menu {
        border-width: 0.5px;
    }

    /* Crisper shadows */
    .shadow-sm {
        box-shadow: 0 0.0625rem 0.125rem rgba(0, 0, 0, 0.075);
    }
}

/* ========================================================================
   REDUCED MOTION - Accessibility
   ======================================================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================================================
   DARK MODE SUPPORT - Future Enhancement
   ======================================================================== */
@media (prefers-color-scheme: dark) {
    /* Placeholder for dark mode styles */
    /* Can be implemented later if needed */
}
