/* ========================================
   🎨 AFFINIX - Modern Design System
   ======================================== */

:root {
    /* Brand Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Neutrals */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #ffffff;
    --sidebar-border: var(--gray-200);

    /* Layout */
    --top-bar-height: 70px;
    --footer-height: 60px;

    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --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);

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Base Styles
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--gray-900);
    background-color: var(--gray-50);
    height: 100%;
    overflow-x: hidden;
}

#app {
    height: 100%;
}

/* ========================================
   App Container
   ======================================== */

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-width: 0;
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ========================================
   Sidebar Navigation
   ======================================== */

.sidebar-nav {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    z-index: 1000;
}

body.sidebar-collapsed .sidebar-nav {
    width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
}

.brand-icon {
    font-size: 1.5rem;
}

body.sidebar-collapsed .brand-name {
    display: none;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.25rem;
    transition: var(--transition);
}

.sidebar-toggle:hover {
    color: var(--primary);
}

.nav-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.nav-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-section-title {
    padding: 0.75rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-600);
}

body.sidebar-collapsed .nav-section-title {
    display: none;
}

.nav-item {
    margin: 0.25rem 0.75rem;
}

.nav-link, .logout-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: var(--transition);
    font-weight: 500;
    width: 100%;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.95rem;
}

.nav-link i, .logout-btn i {
    font-size: 1.25rem;
    width: 1.25rem;
    text-align: center;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
}

body.sidebar-collapsed .nav-link span,
body.sidebar-collapsed .logout-btn span {
    display: none;
}

body.sidebar-collapsed .nav-link,
body.sidebar-collapsed .logout-btn {
    justify-content: center;
    padding: 0.75rem;
}

.nav-link .badge {
    margin-left: auto;
    padding: 0.125rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--secondary);
    color: white;
    border-radius: 1rem;
}

body.sidebar-collapsed .nav-link .badge {
    display: none;
}

.nav-divider {
    height: 1px;
    background: var(--sidebar-border);
    margin: 1rem 1.5rem;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--sidebar-border);
}

.version-info {
    text-align: center;
    color: var(--gray-600);
}

body.sidebar-collapsed .version-info {
    display: none;
}

/* ========================================
   Top Bar
   ======================================== */

.top-bar {
    height: var(--top-bar-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 2rem;
    box-shadow: var(--shadow-sm);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--gray-100);
    border-radius: 2rem;
}

.user-profile i {
    font-size: 1.5rem;
    color: var(--primary);
}

.user-name {
    font-weight: 500;
    color: var(--gray-700);
}

/* ========================================
   Content Area
   ======================================== */

.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 0;
}

/* ========================================
   Footer
   ======================================== */

.app-footer {
    height: var(--footer-height);
    background: white;
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
}

.footer-links a:hover {
    color: var(--primary);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    box-shadow: var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* ========================================
   Forms
   ======================================== */

.form-control, .form-select {
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    padding: 0.625rem 1rem;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

.form-label {
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

/* ========================================
   Cards
   ======================================== */

.card {
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

/* ========================================
   Alerts
   ======================================== */

.alert {
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    border: none;
    margin-bottom: 1rem;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
}

/* ========================================
   Error UI
   ======================================== */

/* Blazor imposta inline "display:block" su questo elemento quando si verifica
   un'eccezione non gestita nel circuit. Lo mostriamo come banner in basso,
   NON come overlay a tutto schermo (altrimenti la pagina appare "tutta scura"
   senza spiegazione, come è successo sulla pagina Questionario). */
#blazor-error-ui {
    background: #ffefc2;
    color: #6b3f00;
    border-top: 1px solid #f0c674;
    box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.15);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    padding: 0.75rem 1.25rem;
    display: none; /* Blazor sovrascrive con display:block inline all'occorrenza */
    font-size: 0.95rem;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}

#blazor-error-ui .reload {
    color: #6b3f00;
    text-decoration: underline;
    margin-left: 0.5rem;
}

.error-container {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 400px;
}

.error-container i {
    font-size: 3rem;
    color: var(--danger);
    margin-bottom: 1rem;
}

.reload-btn {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.5rem 1.5rem;
    background: var(--primary);
    color: white;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: var(--transition);
}

.reload-btn:hover {
    background: var(--primary-dark);
}

.dismiss-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-600);
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 768px) {
    .sidebar-nav {
        transform: translateX(-100%);
    }

    body.sidebar-open .sidebar-nav {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .page-title {
        font-size: 1.25rem;
    }

    .content-area {
        padding: 1rem 0;
    }

    .app-footer {
        font-size: 0.875rem;
    }

    .footer-links {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ========================================
   Utilities
   ======================================== */

.text-muted {
    color: var(--gray-600) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.shadow {
    box-shadow: var(--shadow);
}

.shadow-md {
    box-shadow: var(--shadow-md);
}

.shadow-lg {
    box-shadow: var(--shadow-lg);
}
/* Fix visibility of date value inside Bootstrap form-floating */
.form-floating > input[type="date"].form-control,
.form-floating > input[type="datetime-local"].form-control,
.form-floating > input[type="month"].form-control,
.form-floating > input[type="time"].form-control {
    padding-top: 1.625rem;
    padding-bottom: 0.625rem;
}

