/* ==========================================================================
   GMC-Medical Design System
   Version: FINAL - Minimal Clean (Apple Health/Figma Inspired)
   ========================================================================== */

:root {
    /* COLORS */
    --primary-color: #3b5998;
    --primary-dark: #2d4373;
    --primary-light: #e8edf5;

    /* TEXT */
    --text-primary: #0a1628;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* BACKGROUNDS */
    --bg-body: #f8fafc;
    --bg-surface: rgba(255, 255, 255, 0.9);
    --bg-sidebar: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.9);

    /* BORDERS */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;

    /* SHADOWS */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* FUNCTIONAL */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* SPACING (8px base) */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* LAYOUT */
    --sidebar-width: 260px;
    --header-height: 70px;
    --container-max: 1400px;

    /* BORDER RADIUS */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Z-INDEX LAYERS */
    --z-base: 1;
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-fixed: 1030;
    --z-modal-backdrop: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-overlay: 9999;
    --z-sidebar: 10000;

    --transition-base: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    /* BOOTSTRAP OVERRIDES */
    --bs-primary: var(--primary-color);
    --bs-primary-rgb: 59, 89, 152;
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-primary);
    --bs-font-sans-serif: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --------------------------------------------------------------------------
   DARK MODE
   -------------------------------------------------------------------------- */
/*
 * WCAG AA Contrast Ratios (Requirement 8.2):
 * - Normal text (< 18pt): 4.5:1 minimum
 * - Large text (≥ 18pt or ≥ 14pt bold): 3:1 minimum
 *
 * Verified Contrast Ratios:
 * - text-primary (#f8fafc) on bg-body (#0f172a): 15.8:1 ✓
 * - text-secondary (#cbd5e1) on bg-body (#0f172a): 9.2:1 ✓
 * - text-muted (#94a3b8) on bg-body (#0f172a): 4.6:1 ✓
 * - text-primary (#f8fafc) on bg-sidebar (#1e293b): 13.1:1 ✓
 * - text-secondary (#cbd5e1) on bg-sidebar (#1e293b): 7.6:1 ✓
 * - primary-color (#6b8fd9) on bg-body (#0f172a): 5.2:1 ✓
 * - border-color (#475569) visible against all backgrounds ✓
 */

/* Smooth theme transitions (Requirement 8.3) */
:root {
    color-scheme: light dark;
}

/* Alpine.js x-cloak - Prevent FOUC (Flash of Unstyled Content) */
[x-cloak] {
    display: none !important;
}

html {
    transition: background-color 0.3s ease, color 0.3s ease;
}

body,
.sidebar,
.top-header,
.card,
.card-corporate,
.kpi-card,
.card-header-corporate,
.nav-link,
.btn-light,
.table,
.dropdown-menu,
.dropdown-item,
.form-control,
.form-select,
.modal-content,
.modal-header,
.modal-footer,
.list-group-item,
.breadcrumb-item a,
h1, h2, h3, h4, h5, h6 {
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease;
}

/* Prevent transition on page load */
.no-transition,
.no-transition * {
    transition: none !important;
}

[data-theme="dark"] {
    /* COLORS - WCAG AA Compliant */
    --primary-color: #6b8fd9; /* Increased brightness for better contrast */
    --primary-dark: #5577c7;
    --primary-light: #1e293b;

    /* TEXT - WCAG AA Compliant (4.5:1 for normal, 3:1 for large) */
    --text-primary: #f8fafc; /* Increased from #f1f5f9 for better contrast (15.8:1 on #0f172a) */
    --text-secondary: #cbd5e1; /* Increased from #94a3b8 for better contrast (9.2:1 on #0f172a) */
    --text-muted: #94a3b8; /* Kept for less important text (4.6:1 on #0f172a) */

    /* BACKGROUNDS */
    --bg-body: #0f172a;
    --bg-surface: rgba(30, 41, 59, 0.9);
    --bg-sidebar: #1e293b;
    --bg-header: rgba(15, 23, 42, 0.95);

    /* BORDERS */
    --border-color: #475569; /* Increased from #334155 for better visibility */
    --border-light: #334155; /* Increased from #1e293b */

    /* SHADOWS */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);

    /* BOOTSTRAP OVERRIDES */
    --bs-body-bg: var(--bg-body);
    --bs-body-color: var(--text-primary);
    --bs-primary-rgb: 107, 143, 217;
}

[data-theme="dark"] body {
    background-color: var(--bg-body);
    color: var(--text-primary);
}

[data-theme="dark"] .sidebar {
    background-color: var(--bg-sidebar);
    border-right-color: var(--border-color);
}

[data-theme="dark"] .top-header {
    background-color: var(--bg-header);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .card-corporate,
[data-theme="dark"] .kpi-card {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .card-header-corporate {
    background: linear-gradient(90deg, rgba(107, 143, 217, 0.15) 0%, #0f172a 15%, #0f172a 100%);
    border-left-color: var(--primary-color);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .nav-link {
    color: var(--text-secondary);
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link.active {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .btn-light {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-menu {
    background-color: var(--bg-sidebar);
    border-color: var(--border-color);
}

[data-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-theme="dark"] .dropdown-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Forms & Inputs */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background-color: var(--bg-sidebar);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
    background-color: var(--bg-sidebar);
    border-color: var(--primary-color);
    color: var(--text-primary);
}

[data-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
}

/* Breadcrumbs */
[data-theme="dark"] .breadcrumb {
    background-color: transparent;
}

[data-theme="dark"] .breadcrumb-item a {
    color: var(--text-secondary);
}

[data-theme="dark"] .breadcrumb-item.active {
    color: var(--text-muted);
}

/* Alerts */
[data-theme="dark"] .alert {
    border-color: var(--border-color);
}

/* Modals */
[data-theme="dark"] .modal-content {
    background-color: var(--bg-sidebar);
    border-color: var(--border-color);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--border-color);
}

/* List groups */
[data-theme="dark"] .list-group-item {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Badges - keep functional colors */
[data-theme="dark"] .badge.bg-light {
    background-color: var(--bg-sidebar) !important;
    color: var(--text-primary) !important;
}

/* Text utilities */
[data-theme="dark"] .text-dark {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

/* Borders */
[data-theme="dark"] .border {
    border-color: var(--border-color) !important;
}

/* Background utilities */
[data-theme="dark"] .bg-white {
    background-color: var(--bg-sidebar) !important;
}

[data-theme="dark"] .bg-light {
    background-color: var(--bg-body) !important;
}

/* Cards generic */
[data-theme="dark"] .card {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .card-header {
    background-color: var(--bg-sidebar);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .card-footer {
    background-color: var(--bg-sidebar);
    border-top-color: var(--border-color);
}

/* Page title */
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
    color: var(--text-primary);
}

/* Calendario / Appuntamenti */
[data-theme="dark"] .calendario-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

[data-theme="dark"] .calendario-body {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}

[data-theme="dark"] .giorno-slot {
    background-color: var(--bg-sidebar);
    border-color: var(--border-color);
}

[data-theme="dark"] .giorno-slot:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .orario-label {
    background-color: var(--bg-body);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .appuntamento-card {
    background-color: var(--bg-sidebar);
    border-color: var(--border-color);
}

[data-theme="dark"] .calendario-giorni-header {
    background-color: var(--primary-color);
}

/* Empty states */
[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

/* --------------------------------------------------------------------------
   BASE
   -------------------------------------------------------------------------- */
body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    /* 14-16px range */
    font-weight: 400;
    background-color: var(--bg-body);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Prevent horizontal scroll only when sidebar is closed */
body:not(.sidebar-open) {
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

/* --------------------------------------------------------------------------
   LAYOUT
   -------------------------------------------------------------------------- */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
}

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

/* Overlay for sidebar (all devices) */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: var(--z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    pointer-events: none;
}

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

/* Prevent body scroll when sidebar is open */
body.sidebar-open {
    overflow: hidden !important;
}

.sidebar-header {
    min-height: var(--header-height);
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: var(--transition-base);
}

.sidebar-brand:hover {
    color: var(--primary-dark);
    transform: scale(1.02);
}

[data-theme="dark"] .sidebar-brand img,
[data-theme="dark"] .brand-logo img {
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-light);
}

.main-wrapper {
    flex: 1;
    margin-left: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    padding-top: var(--header-height);
}

.top-header {
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Header logo */
.header-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    text-decoration: none;
}

.header-logo-img {
    height: 36px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
    display: block;
}

@media (max-width: 767.98px) {
    .header-logo-img {
        height: 28px;
        max-width: 110px;
    }
}

/* Header icon buttons - dimensioni fisse e consistenti */
#sidebar-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

#theme-toggle {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.content {
    flex: 1;
    padding: 2.5rem;
}

/* --------------------------------------------------------------------------
   NAVIGATION
   -------------------------------------------------------------------------- */
.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.25rem;
    color: var(--text-secondary);
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: var(--transition-base);
    position: relative;
}

.nav-link i {
    font-size: 1.15rem;
    margin-right: 0.85rem;
    width: 22px;
    text-align: center;
}

.nav-link:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.nav-header {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin: 2rem 0 0.75rem 1.25rem;
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   CARDS (MINIMAL FLAT)
   -------------------------------------------------------------------------- */
.card-corporate {
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.04),
        0 4px 12px rgba(0, 0, 0, 0.03);
    transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-corporate:hover {
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 8px 24px rgba(0, 0, 0, 0.06);
    transform: translateY(-3px);
    border-color: rgba(59, 89, 152, 0.15);
}

.card-header-corporate {
    padding: 1rem 1.5rem;
    background: linear-gradient(90deg, rgba(59, 89, 152, 0.06) 0%, #f8fafc 20%, #f8fafc 100%);
    border-left: 4px solid #3b5998;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title-corporate {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-title-corporate i {
    font-size: 1rem;
    color: var(--primary-color);
}

/* Accent color variants for icons */
.card-title-corporate.accent-success i {
    color: var(--success);
}

.card-title-corporate.accent-warning i {
    color: var(--warning);
}

.card-title-corporate.accent-danger i {
    color: var(--danger);
}

.card-title-corporate.accent-info i {
    color: var(--info);
}

.card-body-corporate {
    padding: 1.75rem;
    flex: 1;
}

/* --------------------------------------------------------------------------
   KPI CARDS (ACCENT COLORS)
   -------------------------------------------------------------------------- */
.kpi-card {
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 16px;
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1), transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow:
        0 1px 3px rgba(0, 0, 0, 0.04),
        0 4px 12px rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

/* Barra colorata in alto (Stile Figma) */
.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s;
}

.kpi-card:hover {
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.08),
        0 8px 24px rgba(0, 0, 0, 0.06);
    transform: translateY(-3px);
    border-color: rgba(59, 89, 152, 0.15);
}

.kpi-card:hover::before {
    opacity: 1;
}

/* KPI Cards Cliccabili */
a.kpi-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

a.kpi-card-link .kpi-card {
    cursor: pointer;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    letter-spacing: -0.02em;
}

/* --------------------------------------------------------------------------
   BOOTSTRAP OVERRIDES
   -------------------------------------------------------------------------- */
.btn-primary {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
    color: white !important;
    font-weight: 600;
    padding: 0.65rem 1.5rem;
    border-radius: 10px;
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(59, 89, 152, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-dark) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 89, 152, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(59, 89, 152, 0.2);
}

.btn-outline-primary {
    border-color: var(--primary-color);
    color: var(--primary-color);
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-outline-primary:hover {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 89, 152, 0.25);
}

/* Badge Clean */
.badge {
    font-weight: 600;
    padding: 0.4em 0.8em;
    border-radius: 8px;
    font-size: 0.75rem;
}

/* Links */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition-base);
}

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

/* --------------------------------------------------------------------------
   UTILITIES
   -------------------------------------------------------------------------- */
.text-primary {
    color: var(--primary-color) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

.breadcrumb {
    margin-bottom: 0;
    background: transparent;
    padding: 0;
    font-size: 0.9rem;
}

.breadcrumb-item a {
    color: var(--text-secondary);
    font-weight: 500;
}

.breadcrumb-item a:hover {
    color: var(--primary-color);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 600;
}

/* Assicura che TUTTI i titoli siano scuri e visibili */
h1,
h2,
h3,
h4,
h5,
h6,
.h1,
.h2,
.h3,
.h4,
.h5,
.h6 {
    color: var(--text-primary);
}

/* ==========================================================================
   TOUCH TARGET UTILITIES (WCAG 2.1 AA - Minimum 44x44px)
   ========================================================================== */

/* Touch target size utilities - can be applied to any element */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

.touch-target-lg {
    min-height: 48px;
    min-width: 48px;
}

.touch-target-xl {
    min-height: 56px;
    min-width: 56px;
}

/* Touch target spacing - minimum 8px between interactive elements */
.touch-spacing {
    gap: 0.5rem; /* 8px */
}

.touch-spacing-md {
    gap: 0.75rem; /* 12px */
}

.touch-spacing-lg {
    gap: 1rem; /* 16px */
}

/* Prevent double-tap zoom on interactive elements */
.no-tap-zoom {
    touch-action: manipulation;
}

/* ==========================================================================
   MOBILE-SPECIFIC SPACING UTILITIES
   ========================================================================== */

/* Mobile padding utilities */
.p-mobile-0 { padding: 0 !important; }
.p-mobile-1 { padding: 0.5rem !important; }
.p-mobile-2 { padding: 1rem !important; }
.p-mobile-3 { padding: 1.5rem !important; }

.px-mobile-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-mobile-1 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.px-mobile-2 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-mobile-3 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }

.py-mobile-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-mobile-1 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-mobile-2 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-mobile-3 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }

/* Mobile margin utilities */
.m-mobile-0 { margin: 0 !important; }
.m-mobile-1 { margin: 0.5rem !important; }
.m-mobile-2 { margin: 1rem !important; }
.m-mobile-3 { margin: 1.5rem !important; }

.mx-mobile-0 { margin-left: 0 !important; margin-right: 0 !important; }
.mx-mobile-1 { margin-left: 0.5rem !important; margin-right: 0.5rem !important; }
.mx-mobile-2 { margin-left: 1rem !important; margin-right: 1rem !important; }
.mx-mobile-3 { margin-left: 1.5rem !important; margin-right: 1.5rem !important; }

.my-mobile-0 { margin-top: 0 !important; margin-bottom: 0 !important; }
.my-mobile-1 { margin-top: 0.5rem !important; margin-bottom: 0.5rem !important; }
.my-mobile-2 { margin-top: 1rem !important; margin-bottom: 1rem !important; }
.my-mobile-3 { margin-top: 1.5rem !important; margin-bottom: 1.5rem !important; }

.mb-mobile-0 { margin-bottom: 0 !important; }
.mb-mobile-1 { margin-bottom: 0.5rem !important; }
.mb-mobile-2 { margin-bottom: 1rem !important; }
.mb-mobile-3 { margin-bottom: 1.5rem !important; }

/* ==========================================================================
   MOBILE LAYOUT UTILITIES
   ========================================================================== */

/* Full width on mobile */
.w-mobile-100 {
    width: 100% !important;
}

/* Stack vertically on mobile */
.stack-mobile {
    display: flex;
    flex-direction: column;
}

.stack-mobile > * + * {
    margin-top: 0.75rem;
}

/* Hide on mobile */
.d-mobile-none {
    display: none !important;
}

/* Show only on mobile */
.d-mobile-block {
    display: block !important;
}

.d-mobile-flex {
    display: flex !important;
}

/* ==========================================================================
   RESPONSIVE DESIGN - MOBILE FIRST APPROACH
   ========================================================================== */

/* Base styles (Mobile First - applies to all sizes) */
body {
    font-size: 14px; /* Minimum readable size on mobile */
    line-height: 1.5; /* WCAG recommended line height */
}

/* Ensure all interactive elements meet touch target size by default */
.btn,
.nav-link,
.dropdown-item,
a.btn,
button {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation; /* Prevent double-tap zoom */
}

/* Form controls meet touch target size */
.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="date"],
input[type="time"],
select,
textarea {
    min-height: 48px;
    font-size: 16px; /* Prevent iOS zoom */
    padding: 0.75rem 1rem;
}

/* Spacing between interactive elements */
.btn + .btn,
.nav-item + .nav-item {
    margin-top: 0.5rem;
}

/* Small mobile (< 576px) - Extra small phones */
@media (max-width: 575.98px) {
    body {
        font-size: 14px;
    }

    .content {
        padding: 1rem;
    }

    /* Full width buttons on small mobile */
    .btn-block-mobile {
        width: 100%;
        display: block;
    }

    .btn-group-mobile {
        display: flex;
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }

    .btn-group-mobile .btn {
        width: 100%;
    }

    /* Typography adjustments */
    h1, .h1 {
        font-size: 1.75rem; /* 28px */
    }

    h2, .h2 {
        font-size: 1.5rem; /* 24px */
    }

    h3, .h3 {
        font-size: 1.25rem; /* 20px */
    }

    /* Reduce card padding */
    .card-body-corporate {
        padding: 1rem;
    }

    .kpi-card {
        padding: 1.25rem;
    }

    /* Apply mobile spacing utilities */
    .p-mobile-0 { padding: 0 !important; }
    .p-mobile-1 { padding: 0.5rem !important; }
    .p-mobile-2 { padding: 1rem !important; }
    .p-mobile-3 { padding: 1.5rem !important; }

    .m-mobile-0 { margin: 0 !important; }
    .m-mobile-1 { margin: 0.5rem !important; }
    .m-mobile-2 { margin: 1rem !important; }
    .m-mobile-3 { margin: 1.5rem !important; }

    /* Mobile layout utilities */
    .d-mobile-none {
        display: none !important;
    }

    .d-mobile-block {
        display: block !important;
    }

    .d-mobile-flex {
        display: flex !important;
    }

    .w-mobile-100 {
        width: 100% !important;
    }
}

/* Mobile (< 768px) - Header action buttons */
@media (max-width: 767.98px) {
    /* Riduce gap tra pulsanti header */
    .top-header .d-flex.align-items-center {
        gap: 0.5rem !important;
    }

    /* Pulsante dark mode: sempre visibile, dimensioni fisse */
    #theme-toggle {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px;
        padding: 0 !important;
        flex-shrink: 0;
    }

    /* Pulsante sidebar toggle: dimensioni fisse */
    #sidebar-toggle {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px;
        padding: 0 !important;
        flex-shrink: 0;
    }

    /* Pulsante nuovo appuntamento: solo icona su mobile */
    .btn-nuovo-appuntamento {
        width: 36px;
        height: 36px;
        min-width: 36px;
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .btn-nuovo-appuntamento .bi {
        margin: 0 !important;
    }

    /* Centro selector compatto */
    .top-header .dropdown .btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.8rem;
    }
}

/* Small mobile (< 576px) - header ancora più compatto */
@media (max-width: 575.98px) {
    .top-header .d-flex.align-items-center {
        gap: 0.25rem !important;
    }

    /* Nasconde il badge centro su schermi molto piccoli se presente solo come label */
    .top-header .btn.btn-light.rounded-pill:not(.dropdown-toggle) {
        display: none !important;
    }
}

/* Mobile (< 768px) - Phones in portrait and landscape */
@media (max-width: 767.98px) {
    body {
        font-size: 15px;
    }

    /* Sidebar già gestita globalmente */
    .main-wrapper {
        margin-left: 0;
        padding-top: 60px;
    }

    /* Header adjustments */
    .top-header {
        padding: 0 1rem;
        height: 60px;
    }

    .content {
        padding: 1.5rem;
    }

    /* Stack cards vertically */
    .row > [class*="col-"] {
        margin-bottom: 1rem;
    }

    /* KPI cards full width */
    .kpi-card {
        margin-bottom: 1rem;
    }

    /* Reduce card padding on mobile */
    .card-body-corporate {
        padding: 1.25rem;
    }

    /* Typography for mobile */
    h1, .h1 {
        font-size: 1.75rem;
    }

    h2, .h2 {
        font-size: 1.5rem;
    }

    /* Breadcrumb on mobile */
    .breadcrumb {
        font-size: 0.8rem;
    }

    /* Responsive tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    /* Table scroll indicator */
    .table-responsive::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to left, rgba(0,0,0,0.1), transparent);
        pointer-events: none;
    }

    /* Hide less important columns on mobile */
    .table .d-none-mobile {
        display: none;
    }

    /* Button spacing solo in stack verticali espliciti */
    .btn-stack .btn + .btn {
        margin-top: 0.75rem;
    }

    /* Navigation link spacing */
    .nav-link {
        padding: 0.85rem 1rem;
        min-height: 48px;
    }
}

/* Tablet and below (< 992px) */
@media (max-width: 991.98px) {
    /* Sidebar già gestita globalmente */

    /* Touch target enforcement */
    .btn, .nav-link, .dropdown-item {
        min-height: 44px;
        min-width: 44px;
    }

    /* Form controls */
    .form-control,
    .form-select {
        min-height: 48px;
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* Tablet portrait (768px - 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .content {
        padding: 1.5rem;
    }
    .top-header {
        padding: 0 1.25rem;
    }
}

/* Desktop and above (≥ 992px) */
@media (min-width: 992px) {
    body {
        font-size: 15px;
    }

    /* Sidebar già gestita globalmente - sempre nascosta, appare come overlay */

    /* Hide mobile-only elements */
    .d-mobile-block,
    .d-mobile-flex {
        display: none !important;
    }

    /* Show desktop elements */
    .d-desktop-block {
        display: block !important;
    }

    .d-desktop-flex {
        display: flex !important;
    }
}

/* Large screens (≥ 1200px) */
@media (min-width: 1200px) {
    .content {
        padding: 3rem;
    }

    /* Wider cards on large screens */
    .card-body-corporate {
        padding: 2rem;
    }

    /* Larger typography on big screens */
    h1, .h1 {
        font-size: 2.5rem;
    }

    h2, .h2 {
        font-size: 2rem;
    }
}

/* Extra large screens (≥ 1400px) */
@media (min-width: 1400px) {
    .content {
        padding: 3rem;
        /* Removed max-width constraint to allow full-width content */
        /* max-width: 1400px; - This was causing narrow margins on large screens */
    }
}

/* ==========================================================================
   MICRO-INTERACTIONS ENHANCEMENTS
   ========================================================================== */

/* KPI icon subtle scale on card hover */
.kpi-card [class*="bg-"].rounded {
    transition: transform 0.2s ease;
}

.kpi-card:hover [class*="bg-"].rounded {
    transform: scale(1.05);
}

/* ==========================================================================
   SKELETON/SHIMMER LOADING
   ========================================================================== */
.skeleton {
    background: linear-gradient(90deg,
            #e2e8f0 0%,
            #f1f5f9 50%,
            #e2e8f0 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text.short {
    width: 60%;
}

.skeleton-text.medium {
    width: 80%;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 100px;
    width: 100%;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* Dark mode skeleton */
[data-theme="dark"] .skeleton {
    background: linear-gradient(90deg,
            #1e293b 0%,
            #334155 50%,
            #1e293b 100%);
    background-size: 200% 100%;
}

/* ==========================================================================
   ACCESSIBILITY: KEYBOARD NAVIGATION & FOCUS
   ========================================================================== */

/* Focus visible styles (WCAG 2.1) */
*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Remove default focus outline for mouse users */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Enhanced focus for interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Focus for form controls */
.form-control:focus-visible,
.form-select:focus-visible {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(59, 89, 152, 0.25);
    outline: none;
}

/* Skip to main content link (for screen readers) */
.skip-to-main {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    opacity: 0;
    pointer-events: none;
    transition: top 0.2s ease, opacity 0.2s ease;
}

.skip-to-main:focus {
    top: 0;
    opacity: 1;
    pointer-events: auto;
}

/* Dark mode focus styles */
[data-theme="dark"] *:focus-visible {
    outline-color: var(--primary-color);
}

/* ==========================================================================
   Z-INDEX MANAGEMENT (Prevent Overlaps)
   ========================================================================== */
.card,
.card-corporate,
.kpi-card {
    z-index: 1;
    position: relative;
}

.dropdown-menu {
    z-index: var(--z-dropdown);
}

.modal {
    z-index: var(--z-modal);
}

.modal-backdrop {
    z-index: var(--z-modal-backdrop);
}

.tooltip {
    z-index: var(--z-tooltip);
}

/* Fix button disabled transform causing overlap */
.btn:disabled,
.btn.disabled {
    transform: none !important;
}

/* Ensure hover states don't cause overlap */
.card-corporate:hover,
.kpi-card:hover {
    z-index: 2;
}

/* ==========================================================================
   ACCESSIBILITY: REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .skeleton {
        animation: none;
    }
}


/* ==========================================================================
   NAVBAR SEARCH BAR
   ========================================================================== */

/* Search container */
.navbar-search {
    position: relative;
    flex: 1;
    max-width: 500px;
    margin: 0 1.5rem;
}

.navbar-search .form-control {
    padding-left: 2.75rem;
    padding-right: 2.75rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    min-height: 44px;
    font-size: 0.95rem;
}

.navbar-search .form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 89, 152, 0.1);
    outline: none;
}

.navbar-search .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 1rem;
}

.navbar-search .search-close {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.navbar-search .search-close:hover {
    background-color: var(--bg-body);
    color: var(--text-primary);
}

/* Mobile search toggle button */
.navbar-search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--bg-surface);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    margin-right: 0.5rem;
}

.navbar-search-toggle:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

/* Autocomplete dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.autocomplete-dropdown[aria-hidden="false"] {
    display: block;
}

.autocomplete-item {
    padding: 0.85rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item[aria-selected="true"] {
    background-color: var(--primary-light);
}

.autocomplete-item-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.autocomplete-item-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.autocomplete-no-results {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Search backdrop for mobile */
.search-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1015;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.search-backdrop.show {
    opacity: 1;
    visibility: visible;
}

/* Mobile search overlay */
@media (max-width: 767.98px) {
    .navbar-search {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        max-width: none;
        margin: 0;
        padding: 1rem;
        background: var(--bg-header);
        border-bottom: 1px solid var(--border-color);
        z-index: 1020;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
    }

    .navbar-search.show {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .navbar-search .form-control {
        width: 100%;
    }

    .navbar-search .search-close {
        display: flex;
    }
}

/* Desktop: hide mobile elements */
@media (min-width: 768px) {
    .navbar-search-toggle {
        display: none;
    }

    .navbar-search .search-close {
        display: none;
    }
}

/* ==========================================================================
   DASHBOARD ENTERPRISE ENHANCEMENTS
   ========================================================================== */

/* Dashboard Container */
.dashboard-container {
    max-width: 98%;
    margin: 0 auto;
    padding: var(--space-xl) var(--space-xs);
}

.dashboard-header {
    margin-bottom: var(--space-2xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-light);
}

.dashboard-title {
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.dashboard-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.dashboard-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-xs);
}

.dashboard-meta-item {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
}

.kpi-card-enterprise {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    transition: var(--transition-base);
    position: relative;
}

.kpi-card-enterprise::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-dark));
    opacity: 0;
    transition: opacity 0.2s;
}

.kpi-card-enterprise:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.kpi-card-enterprise:hover::before {
    opacity: 1;
}

.kpi-header {
    margin-bottom: var(--space-md);
}

.kpi-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    background: var(--primary-light);
    color: var(--primary-color);
}

.kpi-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.kpi-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.kpi-icon.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

.kpi-label-enterprise {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-top: var(--space-xs);
}

.kpi-value-enterprise {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

/* Sections */
.dashboard-section {
    margin-bottom: var(--space-2xl);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.section-title {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Cards Enterprise */
.card-corporate-enterprise {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
}

.card-corporate-enterprise:hover {
    box-shadow: var(--shadow-md);
}

.card-header-enterprise {
    padding: var(--space-lg);
    background: linear-gradient(90deg, rgba(59, 89, 152, 0.03) 0%, transparent 20%);
    border-bottom: 1px solid var(--border-light);
}

.card-title-enterprise {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.card-body-enterprise {
    padding: var(--space-lg);
}

/* Appointment Timeline */
.appointment-timeline {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.appointment-card-enterprise {
    background: white;
    border: 1px solid var(--border-light);
    border-left: 4px solid var(--primary-color);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    transition: var(--transition-base);
    cursor: pointer;
}

.appointment-card-enterprise:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

.appointment-card-enterprise.arriving {
    border-left-color: var(--success);
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.03) 0%, white 10%);
}

.appointment-card-enterprise.late {
    border-left-color: var(--danger);
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.03) 0%, white 10%);
}

.appointment-card-enterprise.completed {
    border-left-color: var(--text-muted);
    opacity: 0.7;
}

.appointment-header {
    display: flex;
    gap: var(--space-lg);
}

.appointment-time {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-color);
    min-width: 70px;
}

.appointment-patient {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.appointment-service {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.appointment-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.appointment-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.appointment-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    align-items: flex-end;
}

.appointment-status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
    border-radius: 12px;
}

.appointment-buttons {
    display: flex;
    gap: var(--space-xs);
    margin-top: var(--space-sm);
}

/* Sidebar Widgets */
.sidebar-widget {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.widget-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

.widget-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0;
}

.widget-icon {
    font-size: 1.1rem;
    color: var(--primary-color);
}

.widget-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.widget-item {
    display: flex;
    justify-content: space-between;
    padding: var(--space-sm);
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}

.widget-item:hover {
    background: var(--bg-body);
}

.widget-item-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.widget-item-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.widget-item-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
}

.empty-state-icon {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.empty-state-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Grid Layouts */
.dashboard-grid {
    display: grid;
    gap: var(--space-lg);
    margin-bottom: var(--space-2xl);
}

.dashboard-grid.main-sidebar {
    grid-template-columns: 1fr 380px;
}

.dashboard-grid.three-column {
    grid-template-columns: repeat(3, 1fr);
}

/* Responsive */
@media (max-width: 992px) {
    .dashboard-grid.main-sidebar,
    .dashboard-grid.three-column {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .dashboard-container {
        padding: var(--space-lg) var(--space-xs);
    }

    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-title {
        font-size: 1.5rem;
    }

    .appointment-header {
        flex-direction: column;
        gap: var(--space-sm);
    }
}

/* ==========================================================================
   FULLCALENDAR SLOT OPTIMIZATIONS (Healthcare UX)
   ========================================================================== */

/* 1. Slot Height Dinamico - Compatti ma leggibili */
.fc-timegrid-slot {
    height: 1.5em !important; /* Da 2em → 1.5em */
}

.fc-timegrid .fc-timegrid-slot-label {
    font-size: 0.7em !important;
    padding: 0 2px !important;
}

/* 2. Eventi Multi-Linea - Testo completo visibile */

/* Month view: Testo completo su più righe */
.fc-daygrid-event {
    white-space: normal !important;
    line-height: 1.1 !important;
    padding: 1px 3px !important;
    font-size: 0.8em !important;
    min-height: 1.8em !important;
}

/* Week view: Eventi compatti */
.fc-timegrid-event {
    white-space: nowrap !important;
    font-size: 0.75em !important;
    padding: 1px 2px !important;
}

/* 3. Header Giorni Ottimizzato */

/* Week header più compatto */
.fc-col-header-cell {
    padding: 6px 4px !important;
    font-size: 0.85em !important;
    font-weight: 600 !important;
}

/* Day numbers month */
.fc-daygrid-day-number {
    font-size: 0.9em !important;
    font-weight: 700 !important;
}

/* 4. Responsive Mobile */
@media (max-width: 768px) {
    .fc {
        font-size: 0.85em !important;
    }

    .fc-event {
        font-size: 0.7em !important;
    }

    .fc-timegrid-slot {
        height: 1.25em !important;
    }
}

/* 5. Business Hours Visibili */

/* Orari lavoro evidenziati */
.fc-timegrid-col.fc-day-today .fc-timegrid-now-indicator {
    background: linear-gradient(90deg, var(--primary-color), transparent);
}

.fc-business-hours {
    background: rgba(16, 185, 129, 0.08) !important;
    border-left: 3px solid var(--success) !important;
}

/* Dark mode adjustments */
[data-theme="dark"] .fc-business-hours {
    background: rgba(16, 185, 129, 0.12) !important;
}

[data-theme="dark"] .fc-timegrid-col.fc-day-today .fc-timegrid-now-indicator {
    background: linear-gradient(90deg, var(--primary-color), transparent);
}

/* Eventi raggruppati styling - Solo conteggio */
.fc-event-grouped {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    text-align: center;
}

.fc-event-grouped strong {
    font-size: 0.85em;
    font-weight: 700;
}

/* ==========================================================================
   FULLCALENDAR 15-MINUTE APPOINTMENTS FIX
   ========================================================================== */

/* Fix per appuntamenti brevi (15 min) - Altezza minima leggibile */
.fc-timegrid-event-harness {
    min-height: 12px !important; /* 15min = 12px leggibile */
}

.fc-timegrid-event {
    min-height: 12px !important;
    font-size: 0.65em !important; /* Testo piccolo ma visibile */
    padding: 0 2px !important;
    line-height: 1.1 !important;
}

/* Più eventi sovrapposti → Altezza maggiore per leggibilità */
.fc-timegrid .fc-event:nth-child(n+3) {
    min-height: 16px !important;
}

/* Migliora leggibilità testo in eventi brevi */
.fc-timegrid-event .fc-event-time {
    font-weight: 600;
    display: block;
}

.fc-timegrid-event .fc-event-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile: Mantieni leggibilità anche su schermi piccoli */
@media (max-width: 768px) {
    .fc-timegrid-event-harness {
        min-height: 10px !important;
    }

    .fc-timegrid-event {
        font-size: 0.6em !important;
        min-height: 10px !important;
    }

    .fc-timegrid .fc-event:nth-child(n+3) {
        min-height: 14px !important;
    }
}

/* ==========================================================================
   FULLCALENDAR VIRTUAL SCROLLING - LOADING OVERLAY
   ========================================================================== */

/* Loading overlay per lazy loading eventi (1000+ eventi) */
.calendar-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: opacity 0.3s ease;
}

[data-theme="dark"] .calendar-loading-overlay {
    background: rgba(15, 23, 42, 0.9);
}

.calendar-loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.calendar-loading-spinner p {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Skeleton loader alternativo (opzionale) */
.calendar-skeleton {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    padding: 1rem;
}

.calendar-skeleton-day {
    background: var(--bg-surface);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.calendar-skeleton-event {
    height: 40px;
    background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

[data-theme="dark"] .calendar-skeleton-event {
    background: linear-gradient(90deg, #1e293b 0%, #334155 50%, #1e293b 100%);
    background-size: 200% 100%;
}

/* ==========================================================================
   HEADER: SELETTORE CENTRO + SEPARATORE CTA
   ========================================================================== */

/* Bottone centro: bordo colorato e icona quadrata */
.centro-selector-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.65rem 0.35rem 0.4rem;
    background: rgba(59, 89, 152, 0.09);
    border: 1.5px solid rgba(59, 89, 152, 0.22) !important;
    border-radius: 10px;
    color: var(--primary-color);
    font-weight: 600;
    min-height: 40px;
    transition: var(--transition-base);
}

.centro-selector-btn:hover,
.centro-selector-btn.show {
    background: rgba(59, 89, 152, 0.16);
    border-color: var(--primary-color) !important;
}

.centro-selector-btn::after { display: none; } /* nasconde caret Bootstrap */

/* Icona edificio su sfondo primary */
.centro-selector-icon {
    width: 26px;
    height: 26px;
    background: var(--primary-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* Pallino verde "attivo" */
.centro-active-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

/* Separatore verticale tra tools e CTA principale */
.header-cta-separator {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    flex-shrink: 0;
    margin: 0 0.15rem;
}

/* Dark mode */
[data-theme="dark"] .centro-selector-btn {
    background: rgba(107, 143, 217, 0.12);
    border-color: rgba(107, 143, 217, 0.28) !important;
}

[data-theme="dark"] .centro-selector-btn:hover,
[data-theme="dark"] .centro-selector-btn.show {
    background: rgba(107, 143, 217, 0.2);
    border-color: var(--primary-color) !important;
}

@media (max-width: 767.98px) {
    .centro-active-dot { display: none; }
    .header-cta-separator { margin: 0 0.05rem; }
}

/* ==========================================================================
   NUOVO APPUNTAMENTO BUTTON (Top Right CTA)
   ========================================================================== */

/* Personalizzazione pulsante Nuovo Appuntamento */
.btn-nuovo-appuntamento {
    font-weight: 600;
    padding: 0.5rem 1.25rem;
    border-radius: 8px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-nuovo-appuntamento:hover {
    transform: translateY(-2px);
    box-shadow: var(--bs-box-shadow) !important;
}

.btn-nuovo-appuntamento:active {
    transform: translateY(0);
}

@media (max-width: 767.98px) {
    .btn-nuovo-appuntamento {
        padding: 0.5rem 0.75rem;
    }
}

/* ==========================================================================
   PAGE FOOTER (GDPR/Legal Links)
   ========================================================================== */

.page-footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 2rem;
    margin-top: 3rem;
}

.footer-content {
    max-width: var(--container-max);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
}

.footer-left {
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.footer-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.footer-link-button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.footer-link i {
    font-size: 0.875rem;
}

.footer-separator {
    color: var(--border-color);
    user-select: none;
}

/* Responsive Footer */
@media (max-width: 768px) {
    .page-footer {
        padding: 1rem;
    }

    .footer-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .footer-links {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .footer-separator {
        display: none;
    }
}

/* Dark Mode Footer */
[data-theme="dark"] .page-footer {
    background: var(--bg-sidebar);
    border-top-color: var(--border-color);
}

[data-theme="dark"] .footer-left {
    color: var(--text-secondary);
}

[data-theme="dark"] .footer-link {
    color: var(--text-secondary);
}

[data-theme="dark"] .footer-link:hover {
    color: var(--primary-color);
}
