/* Be2Sign Backend — aligned to design/DESIGN.md */
:root {
    /* Core tokens */
    --bg: #f7f8fa;
    --surface: #ffffff;
    --fg: #121417;
    --muted: #6b7380;
    --border: #e0e0e0;
    --accent: #E30613;
    --accent-hover: #B30510;
    --accent-deep: #9b0410;
    --accent-soft: rgba(227, 6, 19, 0.12);
    --ink-soft: #2a2f38;
    --mist: #eef1f5;
    --success: #28A745;
    --warning: #FFC107;
    --danger: #9b0410;

    /* Legacy aliases (existing rules) */
    --besquare-red: var(--accent);
    --besquare-red-dark: var(--accent-hover);
    --besquare-red-light: #FF1724;
    --besquare-gray: var(--ink-soft);
    --besquare-gray-dark: var(--fg);
    --besquare-gray-light: var(--muted);
    --besquare-bg: var(--bg);
    --besquare-white: var(--surface);
    --text-dark: var(--fg);
    --text-light: var(--muted);
    --border-color: var(--border);
    --success-color: var(--success);
    --warning-color: var(--warning);
    --danger-color: var(--danger);

    --font-display: "Outfit", "Segoe UI", system-ui, sans-serif;
    --font-body: "Figtree", "Segoe UI", system-ui, sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* Font sizing ottimizzato per iPad */
html {
    font-size: 18px;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--fg);
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
}

/* Headings */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--fg);
    letter-spacing: -0.02em;
    overflow: visible;
    padding-block-end: 0.08em;
}
h1 { font-size: 2rem; font-weight: 700; margin-bottom: 1.25rem; line-height: 1.25; }
h2 { font-size: 1.65rem; font-weight: 700; margin-bottom: 1rem; line-height: 1.3; }
h3 { font-size: 1.35rem; font-weight: 600; margin-bottom: 0.875rem; line-height: 1.3; }
h4 { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.75rem; }
h5 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }
h6 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }

.num, .mono, code {
    font-family: var(--font-mono);
}

/* Buttons BESQUARE Style */
.btn {
    font-family: var(--font-body);
    font-size: 1rem;
    padding: 0.75rem 1.35rem;
    border-radius: 8px;
    font-weight: 600;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.15s ease;
    border: none;
    min-height: 48px;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--surface);
    box-shadow: none;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    color: var(--surface);
    transform: translateY(-1px);
    box-shadow: none;
}

.btn-primary:active {
    background-color: var(--accent-deep);
    transform: translateY(0);
}

.btn-primary:focus-visible,
.btn-outline-primary:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-secondary {
    background-color: var(--ink-soft);
    color: var(--surface);
}

.btn-secondary:hover {
    background-color: var(--fg);
    color: var(--surface);
}

.btn-outline-primary {
    border: 2px solid var(--accent);
    color: var(--accent);
    background-color: transparent;
}

.btn-outline-primary:hover {
    background-color: var(--accent);
    color: var(--surface);
}

.btn-danger {
    background-color: var(--danger);
    color: var(--surface);
}

.btn-success {
    background-color: var(--success);
    color: var(--surface);
}

/* Navigation Bar */
.navbar {
    background-color: var(--fg) !important;
    box-shadow: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 1rem 1.5rem;
    min-height: 64px;
}

.navbar-brand {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--surface) !important;
    display: flex;
    align-items: center;
    gap: 1rem;
    letter-spacing: -0.03em;
}

.navbar-brand img {
    height: 40px;
    width: auto;
}

.nav-link {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.85) !important;
    padding: 0.65rem 1rem !important;
    border-radius: 8px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--surface) !important;
}

.nav-link.active {
    background-color: var(--accent) !important;
    color: var(--surface) !important;
}

/* Cards — flat panels, accent reserved for CTAs */
.card {
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: none;
    margin-bottom: 1.5rem;
    background-color: var(--surface);
}

.card-header {
    background-color: var(--surface);
    color: var(--fg);
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    padding: 1rem 1.25rem;
    border-radius: 10px 10px 0 0 !important;
    border-bottom: 1px solid var(--border);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--fg);
    margin-bottom: 1rem;
}

/* Forms */
.form-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--fg);
    margin-bottom: 0.5rem;
}

.form-control,
.form-select {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    min-height: 48px;
    background: var(--surface);
    color: var(--fg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    outline: none;
}

.form-check-input {
    width: 1.35rem;
    height: 1.35rem;
    border: 1px solid var(--border);
    cursor: pointer;
}

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

.form-check-label {
    font-size: 1rem;
    margin-left: 0.5rem;
    cursor: pointer;
}

/* Tables */
.table {
    font-size: 1rem;
}

.table thead th {
    background-color: var(--mist);
    color: var(--fg);
    font-weight: 700;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    font-size: 1rem;
    border-color: var(--border);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(18, 20, 23, 0.02);
}

.table-hover tbody tr:hover {
    background-color: var(--mist);
}

/* Alerts */
.alert {
    font-size: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    border: 1px solid transparent;
    border-left-width: 4px;
}

.alert-success {
    background-color: #e8f5ec;
    border-color: var(--success);
    color: #1e6b35;
}

.alert-danger {
    background-color: #fde8ea;
    border-color: var(--danger);
    color: var(--danger);
}

.alert-warning {
    background-color: #fff8e6;
    border-color: var(--warning);
    color: #856404;
}

.alert-info {
    background-color: var(--mist);
    border-color: var(--ink-soft);
    color: var(--ink-soft);
}

/* Badges */
.badge {
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-weight: 600;
}

.badge-primary,
.badge.bg-primary {
    background-color: var(--accent) !important;
}

.badge-success,
.badge.bg-success {
    background-color: var(--success) !important;
}

.badge-danger,
.badge.bg-danger {
    background-color: var(--danger) !important;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    background:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(227, 6, 19, 0.22), transparent 55%),
        linear-gradient(160deg, #121417 0%, #1a1d24 55%, #121417 100%);
    padding: 2rem 2rem 2.5rem;
}

.login-card {
    background-color: var(--surface);
    border-radius: 12px;
    box-shadow: none;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2.5rem;
    max-width: 440px;
    width: 100%;
}

.login-logo {
    max-width: 260px;
    height: auto;
    margin: 0 auto 1.25rem;
    display: block;
}

.login-title {
    font-family: var(--font-display);
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--fg);
    margin-bottom: 0.35rem;
    text-align: center;
    letter-spacing: -0.03em;
}

.login-subtitle {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: 1.75rem;
    text-align: center;
}

.login-brand-mark {
    display: block;
    width: 2.5rem;
    height: 3px;
    background: var(--accent);
    margin: 0.35rem auto 1rem;
    border-radius: 2px;
}

/* Sidebar Navigation */
.sidebar {
    background: linear-gradient(180deg, var(--fg) 0%, #1a1d24 100%);
    min-height: 100vh;
    padding: 1.25rem 0;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

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

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.72);
    padding: 0.85rem 1.15rem;
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background-color 0.2s ease, color 0.2s ease;
    border-left: 3px solid transparent;
    border-radius: 0 8px 8px 0;
    margin-right: 0.5rem;
    min-height: 48px;
}

.sidebar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--surface);
    border-left-color: rgba(227, 6, 19, 0.5);
}

.sidebar .nav-link.active {
    background-color: var(--accent);
    color: var(--surface);
    border-left-color: var(--accent-deep);
    font-weight: 600;
}

.sidebar .nav-link i {
    font-size: 1.15rem;
    width: 24px;
    text-align: center;
}

.nav-section-label {
    font-family: var(--font-mono);
    font-size: 0.68rem !important;
    letter-spacing: 0.08em !important;
}

/* Syncfusion — keep charts; restyle chrome only */
.e-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: none;
}

.e-card .e-card-header {
    background-color: var(--surface);
    color: var(--fg);
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.e-btn.e-primary {
    background-color: var(--accent);
    border-color: var(--accent);
    font-size: 1rem;
    min-height: 48px;
}

.e-btn.e-primary:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
}

.e-grid .e-headercell {
    background-color: var(--mist);
    color: var(--fg);
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.e-grid .e-rowcell {
    font-size: 1rem;
    padding: 0.85rem;
}

/* Grid compatta per lista documenti */
.grid-compact .e-headercell {
    font-size: 0.8rem;
    padding: 0.5rem 0.4rem;
    white-space: normal;
    line-height: 1.3;
}

.grid-compact .e-rowcell {
    font-size: 0.82rem;
    padding: 0.4rem 0.4rem;
    line-height: 1.4;
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
}

.grid-compact .badge {
    font-size: 0.72rem;
    padding: 0.25rem 0.5rem;
}

.grid-compact .btn-grid {
    min-height: 32px;
    padding: 0.25rem 0.45rem;
    font-size: 0.82rem;
}

.grid-compact .text-muted {
    font-size: 0.75rem;
}

/* Responsive per iPad */
@media (max-width: 1024px) {
    html {
        font-size: 20px;
    }
    
    .btn {
        min-height: 52px;
        font-size: 1.15rem;
    }
    
    .form-control,
    .form-select {
        min-height: 54px;
        font-size: 1.15rem;
    }
    
    .navbar-brand {
        font-size: 1.85rem;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 18px;
    }
    
    .login-card {
        padding: 2rem;
    }
    
    .card-body {
        padding: 1.25rem;
    }
}

/* Utilities */
.text-besquare-red {
    color: var(--besquare-red) !important;
}

.bg-besquare-red {
    background-color: var(--besquare-red) !important;
}

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

.bg-besquare-gray {
    background-color: var(--besquare-gray) !important;
}

/* Spacing utilities per iPad */
.p-ipad {
    padding: 1.5rem !important;
}

.m-ipad {
    margin: 1.5rem !important;
}

.mt-ipad {
    margin-top: 1.5rem !important;
}

.mb-ipad {
    margin-bottom: 1.5rem !important;
}

/* Touch-friendly interactive elements */
a, button, .clickable {
    min-height: 44px; /* iOS/iPad touch target recommendation */
    display: inline-flex;
    align-items: center;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--besquare-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--besquare-gray-light);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--besquare-red);
}

/* Loading spinner BESQUARE style */
.spinner-besquare {
    border: 4px solid var(--besquare-bg);
    border-top: 4px solid var(--besquare-red);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}




