﻿@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* ==========================================================
   H2H BACKOFFICE — Design System v1
   iOS Style Guide · Material You · Lexend / Manrope
   ========================================================== */

/* ── DESIGN TOKENS ─────────────────────────────────────── */
:root {
    /* Material You — Hard Court (default) */
    --c-primary:                  #004590;
    --c-on-primary:               #fff;
    --c-primary-container:        #2a5daa;
    --c-on-primary-container:     #c8d8ff;
    --c-secondary:                #4f5e7e;
    --c-on-secondary:             #fff;
    --c-secondary-container:      #cadaff;
    --c-on-secondary-container:   #4f5f7f;
    --c-surface:                  #f9f9ff;
    --c-on-surface:               #191c21;
    --c-on-surface-variant:       #424751;
    --c-surface-container:        #ededf4;
    --c-surface-container-low:    #f3f3fa;
    --c-surface-container-lowest: #fff;
    --c-surface-container-high:   #e7e7ef;
    --c-surface-container-highest:#e2e2e9;
    --c-outline:                  #737782;
    --c-outline-variant:          #c3c6d3;

    /* Dark shell (sidebar / topbar) */
    --shell-bg:       #0e1118;
    --shell-surface:  #161b26;
    --shell-surface2: #1e2535;
    --shell-border:   rgba(255, 255, 255, 0.07);
    --shell-text:     #e8edf8;
    --shell-text-dim: rgba(232, 237, 248, 0.48);
    --shell-accent:   #4d8eff;

    /* Typography */
    --font-display: 'Lexend', sans-serif;
    --font-body:    'Manrope', sans-serif;

    /* Spacing */
    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 16px;
    --sp-lg: 24px;
    --sp-xl: 40px;

    /* Radii */
    --r-sm:   6px;
    --r-md:   10px;
    --r-lg:   16px;
    --r-pill: 999px;

    /* Bootstrap overrides via custom props */
    --bs-primary:          #004590;
    --bs-primary-rgb:      0, 69, 144;
    --bs-link-color:       #004590;
    --bs-font-sans-serif:  'Manrope', sans-serif;
    --bs-border-radius:    10px;
    --bs-border-radius-sm: 6px;
    --bs-border-radius-lg: 16px;
}

/* ── BASE ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    font-family: var(--font-body);
    height: 100%;
    overflow: hidden;
    background: var(--c-surface);
    color: var(--c-on-surface);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.01em;
}

a, .btn-link { color: var(--c-primary); text-decoration: none; }
a:hover, .btn-link:hover { color: var(--c-primary-container); }

/* ── PAGE LAYOUT ───────────────────────────────────────── */
.page { display: flex; flex-direction: row; height: 100vh; }

/* ── SIDEBAR ───────────────────────────────────────────── */
.sidebar {
    width: 250px;
    min-width: 250px;
    background: var(--shell-bg);
    border-right: 1px solid var(--shell-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease, min-width 0.25s ease, opacity 0.2s ease;
}

.sidebar-hidden {
    width: 0 !important;
    min-width: 0 !important;
    opacity: 0;
    pointer-events: none;
}

.sidebar-brand {
    border-bottom: 1px solid var(--shell-border);
    padding: 14px 16px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-logo-link { display: flex; align-items: center; flex: 1; min-width: 0; }
.sidebar-logo { height: 30px; width: auto; display: block; max-width: 160px; }

/* Icona logo nella sidebar (quadrata, più grande) */
.sidebar-logo-icon {
    height: 200px;
    width: 200px;
    object-fit: contain;
    display: block;
}

/* Top-row: logo orizzontale grande + subtitle */
.topbar-logo {
    width: 200px;
    height: 120px;
    object-fit: contain;
    display: inline-block;
    vertical-align: middle;
}

.topbar-logo-fallback {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 900;
    color: var(--shell-text);
    vertical-align: middle;
}

.topbar-subtitle {
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--shell-text-dim);
    vertical-align: middle;
    margin-left: 0.25rem;
}

.sidebar-section-label {
    color: var(--shell-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-family: var(--font-display);
    font-size: 0.63rem;
    font-weight: 800;
    padding: 0.35rem 1rem 0.1rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    padding-top: 0.5rem;
    overflow-y: auto;
    flex: 1;
}

.sidebar-nav .nav-link {
    color: var(--shell-text-dim);
    border-radius: var(--r-sm);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    transition: background 0.15s, color 0.15s, border-left-color 0.15s;
    white-space: nowrap;
    border-left: 2px solid transparent;
}

.sidebar-nav .nav-link:hover {
    color: var(--shell-text);
    background: rgba(77, 142, 255, 0.1);
    border-left-color: var(--shell-accent);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(77, 142, 255, 0.18);
    border-left-color: var(--shell-accent);
}

.sidebar-nav .nav-link .oi {
    width: 1.6rem;
    font-size: 0.9rem;
    vertical-align: middle;
    opacity: 0.7;
}

.sidebar-nav .nav-link.active .oi,
.sidebar-nav .nav-link:hover .oi { opacity: 1; }

.sidebar-nav hr { border-color: var(--shell-border); margin: 0.25rem 1rem; }

.sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.8rem;
    height: 1.8rem;
    padding: 0;
    background: transparent;
    border: 1px solid var(--shell-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    color: var(--shell-text-dim);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.sidebar-close-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

.sidebar-reopen-btn {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1100;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    background: var(--shell-bg);
    border: 1px solid var(--shell-border);
    border-radius: var(--r-sm);
    cursor: pointer;
    color: var(--shell-text-dim);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    transition: background 0.15s, color 0.15s;
}

.sidebar-reopen-btn:hover { background: var(--shell-surface); color: var(--shell-text); }

/* ── MAIN / TOP-ROW / CONTENT ──────────────────────────── */
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.top-row {
    background: var(--shell-surface);
    border-bottom: 1px solid var(--shell-border);
    min-height: 3.5rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem;
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--shell-text-dim);
}

.top-row .text-muted { color: var(--shell-text-dim) !important; }

.content { flex: 1; overflow-y: auto; overflow-x: auto; padding: 1.5rem; background: var(--c-surface); }

/* ── BOOTSTRAP COMPONENT OVERRIDES ────────────────────── */

/* Buttons */
.btn-primary {
    background-color: var(--c-primary);
    border-color: var(--c-primary);
    color: var(--c-on-primary);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    border-radius: var(--r-md);
    padding: 0.55rem 1.25rem;
    transition: background-color 0.2s, box-shadow 0.2s, transform 0.12s;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--c-primary-container);
    border-color: var(--c-primary-container);
    color: var(--c-on-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 69, 144, 0.3);
}

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

.btn-secondary {
    background-color: var(--c-secondary-container);
    border-color: var(--c-secondary-container);
    color: var(--c-on-secondary-container);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    border-radius: var(--r-md);
}

.btn-outline-primary {
    color: var(--c-primary);
    border-color: var(--c-outline-variant);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    border-radius: var(--r-md);
}

.btn-outline-primary:hover {
    background-color: var(--c-surface-container-high);
    border-color: var(--c-primary);
    color: var(--c-primary);
}

.btn-outline-secondary,
.btn-danger,
.btn-success,
.btn-warning,
.btn-info {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.06em;
    border-radius: var(--r-md);
}

.btn-sm { font-size: 0.72rem; padding: 0.3rem 0.8rem; }
.btn-lg { font-size: 0.9rem; padding: 0.7rem 1.6rem; }

/* Cards */
.card {
    background: var(--c-surface-container-lowest);
    border: 1px solid var(--c-outline-variant);
    border-radius: var(--r-lg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.card-header {
    background: var(--c-surface-container);
    border-bottom: 1px solid var(--c-outline-variant);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    border-radius: var(--r-lg) var(--r-lg) 0 0 !important;
    padding: 0.75rem 1.25rem;
}

.card-title {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1rem;
    letter-spacing: -0.01em;
    color: var(--c-on-surface);
}

/* Tables */
.table { font-family: var(--font-body); font-size: 0.85rem; color: var(--c-on-surface); }

.table thead th {
    font-family: var(--font-display);
    font-weight: 800;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    font-size: 0.68rem;
    color: var(--c-on-surface-variant);
    background: var(--c-surface-container);
    border-bottom: 1px solid var(--c-outline-variant);
    padding: 0.65rem 0.75rem;
}

.table tbody tr { transition: background 0.12s; }
.table-hover tbody tr:hover { background: var(--c-surface-container-low); }
.table tbody td { border-color: var(--c-outline-variant); vertical-align: middle; padding: 0.6rem 0.75rem; }
.table-striped tbody tr:nth-of-type(odd) { background: var(--c-surface-container-low); }

/* Forms */
.form-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    color: var(--c-on-surface-variant);
    margin-bottom: 0.35rem;
}

.form-control, .form-select {
    border: 1px solid var(--c-outline-variant);
    border-radius: var(--r-md);
    font-family: var(--font-body);
    font-size: 0.875rem;
    background: var(--c-surface-container-lowest);
    color: var(--c-on-surface);
    transition: border-color 0.15s, box-shadow 0.15s;
    padding: 0.5rem 0.85rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--c-primary);
    box-shadow: 0 0 0 3px rgba(0, 69, 144, 0.15);
    outline: none;
}

.form-control:disabled, .form-select:disabled {
    background: var(--c-surface-container);
    color: var(--c-on-surface-variant);
}

.form-check-input:checked {
    background-color: var(--c-primary);
    border-color: var(--c-primary);
}

.input-group-text {
    background: var(--c-surface-container);
    border-color: var(--c-outline-variant);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--c-on-surface-variant);
}

/* Badges */
.badge {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    border-radius: var(--r-pill);
    padding: 0.28em 0.7em;
}

.bg-primary { background-color: var(--c-primary) !important; }
.text-primary { color: var(--c-primary) !important; }

/* Alerts */
.alert {
    border-radius: var(--r-lg);
    font-family: var(--font-body);
    font-size: 0.875rem;
    border: 1px solid transparent;
}

/* Modals */
.modal-content {
    border-radius: var(--r-lg);
    border: 1px solid var(--c-outline-variant);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
}

.modal-header {
    border-bottom: 1px solid var(--c-outline-variant);
    font-family: var(--font-display);
    font-weight: 700;
    background: var(--c-surface-container);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}

.modal-title { font-family: var(--font-display); font-weight: 800; font-size: 1rem; }

.modal-footer {
    border-top: 1px solid var(--c-outline-variant);
    background: var(--c-surface-container-low);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* Nav tabs */
.nav-tabs { border-bottom: 1px solid var(--c-outline-variant); }

.nav-tabs .nav-link {
    font-family: var(--font-display);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--c-on-surface-variant);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0.6rem 1rem;
    transition: color 0.15s, border-color 0.15s;
}

.nav-tabs .nav-link:hover { color: var(--c-primary); border-bottom-color: rgba(0, 69, 144, 0.3); }
.nav-tabs .nav-link.active { color: var(--c-primary); background: transparent; border-bottom-color: var(--c-primary); font-weight: 800; }

/* Pagination */
.page-link { color: var(--c-primary); border-color: var(--c-outline-variant); font-family: var(--font-display); font-size: 0.8rem; font-weight: 600; }
.page-link:hover { color: var(--c-primary-container); }
.page-item.active .page-link { background-color: var(--c-primary); border-color: var(--c-primary); }

/* Dropdown */
.dropdown-menu {
    border: 1px solid var(--c-outline-variant);
    border-radius: var(--r-lg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-family: var(--font-body);
    font-size: 0.875rem;
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: var(--r-sm);
    color: var(--c-on-surface);
    padding: 0.45rem 0.85rem;
    font-weight: 500;
    transition: background 0.12s;
}

.dropdown-item:hover, .dropdown-item:focus { background: var(--c-surface-container); color: var(--c-primary); }

.dropdown-header {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--c-on-surface-variant);
    padding: 0.4rem 0.85rem 0.2rem;
}

/* Spinner */
.spinner-border { color: var(--c-primary); }

/* ── BLAZOR SYSTEM ─────────────────────────────────────── */
#blazor-error-ui {
    background: var(--shell-surface);
    border-top: 1px solid rgba(229, 57, 53, 0.4);
    color: #e8edf8;
    bottom: 0;
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.4);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-family: var(--font-body);
    font-size: 0.875rem;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; color: var(--shell-text-dim); }

.blazor-error-boundary {
    background: #3b0a0a;
    border: 1px solid rgba(229, 57, 53, 0.4);
    border-radius: var(--r-lg);
    padding: 1rem 1rem 1rem 3.7rem;
    color: #ffcdd2;
    font-family: var(--font-body);
}

.blazor-error-boundary::after { content: "Si e verificato un errore."; }

/* ── LEAGUE SCHEDULE ───────────────────────────────── */
.schedule-day-card { border: 1px solid var(--c-outline-variant); }
.schedule-day-card:hover { border-color: var(--c-primary); }
.matchup-row { background: var(--c-surface-container-low); border: 1px solid var(--c-outline-variant); transition: background .15s; }
.matchup-row:hover { background: var(--c-surface-container); }
.matchup-completed { opacity: .7; }

/* ── FORM VALIDATION ───────────────────────────────────── */
.valid.modified:not([type=checkbox]) { outline: 1px solid #16a34a; border-color: #16a34a; }
.invalid { outline: 1px solid #e53935; border-color: #e53935; }
.validation-message { color: #e53935; font-family: var(--font-body); font-size: 0.78rem; font-weight: 600; margin-top: 0.2rem; }

/* ── MOBILE ────────────────────────────────────────────── */
@media (max-width: 640px) {
    .sidebar { position: fixed; z-index: 1050; height: 100vh; top: 0; left: 0; }
    .sidebar-hidden { width: 0 !important; min-width: 0 !important; }
    .top-row { padding: 0 1rem; }
    .content { padding: 1rem; }
}

/* ── COMPACT MODE (zoom 80%) ───────────────────────────── */
.page.compact {
    zoom: 0.8;
    height: calc(100vh / 0.8);
}

.compact-toggle-btn {
    background: transparent;
    border: 1px solid var(--shell-border);
    color: var(--shell-text-dim);
    font-family: var(--font-body);
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.compact-toggle-btn:hover {
    color: var(--shell-text);
    border-color: var(--shell-accent);
}
.compact-toggle-label {
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* ── HEALTH BADGE (Firebase) ───────────────────────────── */
.health-badge {
    background: transparent;
    border: 1px solid var(--shell-border);
    color: var(--shell-text-dim);
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    margin-right: 8px;
    border-radius: var(--r-sm);
    cursor: pointer;
}
.health-badge:hover { color: var(--shell-text); }
.health-badge:disabled { cursor: wait; }
.health-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9e9e9e;
}
.health-ok .health-dot { background: #2e7d32; }
.health-off .health-dot { background: #9e9e9e; }
.health-checking .health-dot { background: #f9a825; }
.health-error { border-color: #c62828; color: #c62828; }
.health-error .health-dot { background: #c62828; }

.health-error-banner {
    border: 1px solid #c62828;
    border-left-width: 4px;
    background: rgba(198, 40, 40, 0.06);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    font-size: 0.82rem;
}
.health-error-banner-head {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #c62828;
}
.health-error-banner-time { color: var(--shell-text-dim); font-size: 0.75rem; }
.health-error-banner-btn {
    background: transparent;
    border: 1px solid #c62828;
    color: #c62828;
    border-radius: var(--r-sm);
    font-size: 0.72rem;
    padding: 2px 8px;
    cursor: pointer;
}
.health-error-banner-btn:disabled { cursor: wait; opacity: 0.6; }
.health-error-banner-msg {
    display: block;
    margin-top: 6px;
    white-space: pre-wrap;
    word-break: break-word;
    user-select: all;
}
.health-error-banner-hint { margin-top: 6px; }
