/* ============================================================
   BASE.CSS — Fixtor v2.0.0 Design System
   Palette: deep navy + electric blue accent
   Font: DM Sans (corpo) + DM Mono (dati numerici)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ============================================================
   TEMA SCURO — default
   ============================================================ */
:root,
[data-theme="dark"] {

    /* Colori brand */
    --fx-accent:        #4F7CFF;
    --fx-accent-hover:  #3A67F0;
    --fx-accent-dim:    rgba(79,124,255,0.15);
    --fx-accent-glow:   rgba(79,124,255,0.30);

    /* Superfici — scala di profonditÃ  */
    --surface-base:     #0C0E14;   /* sfondo app */
    --surface-0:        #0C0E14;
    --surface-1:        #12151F;   /* sidebar */
    --surface-2:        #181C2A;   /* card, pannelli */
    --surface-3:        #1E2235;   /* input, hover */
    --surface-4:        #252A40;   /* hover secondario */

    /* Bordi */
    --border-subtle:    rgba(255,255,255,0.05);
    --border-default:   rgba(255,255,255,0.09);
    --border-strong:    rgba(255,255,255,0.16);

    /* Testo */
    --text-primary:     #E8EAF2;
    --text-secondary:   rgba(232,234,242,0.60);
    --text-muted:       rgba(232,234,242,0.35);
    --text-accent:      #4F7CFF;

    /* Stato */
    --color-success:    #34D399;
    --color-success-bg: rgba(52,211,153,0.10);
    --color-warning:    #FBBF24;
    --color-warning-bg: rgba(251,191,36,0.10);
    --color-danger:     #F87171;
    --color-danger-bg:  rgba(248,113,113,0.10);
    --color-info:       #60A5FA;
    --color-info-bg:    rgba(96,165,250,0.10);

    /* Sidebar */
    --sidebar-width:        220px;
    --sidebar-width-collapsed: 60px;
    --sidebar-bg:           #0E1018;
    --sidebar-border:       rgba(255,255,255,0.06);
    --sidebar-item-hover:   rgba(79,124,255,0.08);
    --sidebar-item-active:  rgba(79,124,255,0.14);
    --sidebar-item-active-border: #4F7CFF;
    --sidebar-text:         rgba(232,234,242,0.55);
    --sidebar-text-active:  #E8EAF2;

    /* Shadow */
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
    --shadow-md:  0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg:  0 8px 32px rgba(0,0,0,0.5);
    --shadow-xl:  0 16px 48px rgba(0,0,0,0.6);

    /* Radius */
    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Transizioni */
    --t-fast:   0.12s ease;
    --t-base:   0.22s ease;
    --t-slow:   0.35s ease;

    /* Layout */
    --header-height: 56px;
}

/* ============================================================
   TEMA CHIARO
   ============================================================ */
[data-theme="light"] {

    --fx-accent:        #2F5FD9;
    --fx-accent-hover:  #1E4DC8;
    --fx-accent-dim:    rgba(47,95,217,0.10);
    --fx-accent-glow:   rgba(47,95,217,0.20);

    --surface-base:     #F0F2F8;
    --surface-0:        #F0F2F8;
    --surface-1:        #FFFFFF;
    --surface-2:        #FFFFFF;
    --surface-3:        #F5F6FA;
    --surface-4:        #ECEEF5;

    --border-subtle:    rgba(0,0,0,0.04);
    --border-default:   rgba(0,0,0,0.08);
    --border-strong:    rgba(0,0,0,0.15);

    --text-primary:     #111827;
    --text-secondary:   #4B5568;
    --text-muted:       #9CA3AF;
    --text-accent:      #2F5FD9;

    --color-success:    #059669;
    --color-success-bg: #D1FAE5;
    --color-warning:    #D97706;
    --color-warning-bg: #FEF3C7;
    --color-danger:     #DC2626;
    --color-danger-bg:  #FEE2E2;
    --color-info:       #2563EB;
    --color-info-bg:    #DBEAFE;

    --sidebar-bg:           #FFFFFF;
    --sidebar-border:       rgba(0,0,0,0.07);
    --sidebar-item-hover:   rgba(47,95,217,0.06);
    --sidebar-item-active:  rgba(47,95,217,0.10);
    --sidebar-item-active-border: #2F5FD9;
    --sidebar-text:         #5A6278;
    --sidebar-text-active:  #111827;

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.10);
    --shadow-lg:  0 8px 24px rgba(0,0,0,0.12);
    --shadow-xl:  0 16px 40px rgba(0,0,0,0.14);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    height: 100%;
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.6;
    background: var(--surface-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition:
        background var(--t-base),
        color var(--t-base);
}

/* Tema flash prevention */
html:not([data-theme]) { visibility: hidden; }

a {
    color: var(--fx-accent);
    text-decoration: none;
    transition: color var(--t-fast);
}
a:hover { color: var(--fx-accent-hover); }

img, svg { display: block; max-width: 100%; }

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* ============================================================
   TIPOGRAFIA — scale
   ============================================================ */
.text-xs   { font-size: 0.75rem;   line-height: 1.5; }
.text-sm   { font-size: 0.8125rem; line-height: 1.5; }
.text-base { font-size: 0.9375rem; line-height: 1.6; }
.text-lg   { font-size: 1.0625rem; line-height: 1.5; }
.text-xl   { font-size: 1.25rem;   line-height: 1.4; }
.text-2xl  { font-size: 1.5rem;    line-height: 1.3; }
.text-3xl  { font-size: 1.875rem;  line-height: 1.25; }

.fw-300 { font-weight: 300; }
.fw-400 { font-weight: 400; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

.font-mono { font-family: 'DM Mono', monospace; }

.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted     { color: var(--text-muted); }
.text-accent    { color: var(--text-accent); }
.text-success   { color: var(--color-success); }
.text-warning   { color: var(--color-warning); }
.text-danger    { color: var(--color-danger); }

/* ============================================================
   BADGE
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    line-height: 1.6;
    white-space: nowrap;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info); }
.badge-neutral { background: var(--surface-3);        color: var(--text-secondary); }
.badge-accent  { background: var(--fx-accent-dim);    color: var(--fx-accent); }

/* ============================================================
   BUTTON
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    transition: all var(--t-fast);
    cursor: pointer;
    white-space: nowrap;
}

.btn-primary {
    background: var(--fx-accent);
    color: #fff;
    border: 1px solid transparent;
}
.btn-primary:hover { background: var(--fx-accent-hover); }

.btn-secondary {
    background: var(--surface-3);
    color: var(--text-primary);
    border: 1px solid var(--border-default);
}
.btn-secondary:hover { background: var(--surface-4); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
}
.btn-ghost:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid transparent;
}
.btn-danger:hover { background: var(--color-danger); color: #fff; }

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8125rem;
}

.btn-icon {
    padding: 7px;
    aspect-ratio: 1;
}

/* ============================================================
   CARD
   ============================================================ */
.card {
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.2px;
}

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    background: var(--surface-3);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: border-color var(--t-fast), box-shadow var(--t-fast);
    outline: none;
    width: 100%;
}

.form-control:focus {
    border-color: var(--fx-accent);
    box-shadow: 0 0 0 3px var(--fx-accent-dim);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    background: var(--surface-3);
    text-align: left;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
}

.table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-3); }

/* ============================================================
   UTILITY
   ============================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}

.flex        { display: flex; }
.flex-col    { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-1 { gap: 4px;  }
.gap-2 { gap: 8px;  }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }
.gap-6 { gap: 24px; }

.w-full  { width: 100%; }
.h-full  { height: 100%; }
.ml-auto { margin-left: auto; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.divider {
    height: 1px;
    background: var(--border-subtle);
    border: none;
    margin: 16px 0;
}

/* Dot status */
.dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}
.dot-green  { background: var(--color-success); }
.dot-yellow { background: var(--color-warning); }
.dot-red    { background: var(--color-danger); }
.dot-blue   { background: var(--fx-accent); }
.dot-muted  { background: var(--text-muted); }

/* Numeric mono */
.num {
    font-family: 'DM Mono', monospace;
    font-size: 0.875rem;
    letter-spacing: -0.3px;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   PAGE 404
   ============================================================ */
.page-404 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 60vh;
    gap: 12px;
    color: var(--text-muted);
}
.page-404 h1 {
    font-size: 4rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* ============================================================
   MODAL — globale, disponibile su tutte le pagine
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.15s ease;
}

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

.modal {
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    box-shadow: var(--shadow-xl);
    animation: slideUp 0.2s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.25rem;
    line-height: 1;
    transition: background var(--t-fast), color var(--t-fast);
    cursor: pointer;
    border: none;
    background: none;
}

.modal-close:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px 18px;
    border-top: 1px solid var(--border-subtle);
}

.modal-footer .btn-danger {
    margin-right: auto;
}

/* ---- Empty state — globale ---- */
.dash-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 4px;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.dash-empty svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
    opacity: 0.5;
}