/* =========================================================
   Laboratest — Piano Alimentare Platform
   Color palette:
     Primary blue:  #2c5aa0
     Dark blue:     #1e3f73
     Light bg:      #f4f6f9
     Sidebar bg:    #ffffff
     Text dark:     #2d3748
     Text muted:    #718096
     Border:        #e2e8f0
   ========================================================= */

:root {
    --color-primary: #2c5aa0;
    --color-primary-dark: #1e3f73;
    --color-primary-light: #e8eef6;
    --color-bg: #f4f6f9;
    --color-white: #ffffff;
    --color-text: #2d3748;
    --color-text-muted: #718096;
    --color-border: #e2e8f0;
    --sidebar-w: 260px;
    --topbar-h: 60px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    color: var(--color-text);
    background: var(--color-bg);
    margin: 0;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}

/* =========================================================
   LOGIN PAGE
   ========================================================= */

.login-body {
    background: linear-gradient(135deg, #f4f6f9 0%, #dfe6ed 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--color-white);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    padding: 2.5rem 2rem 2rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.brand-name {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.5px;
    margin: 0;
}

.login-header .text-muted {
    font-size: 0.9rem;
    color: var(--color-text-muted) !important;
}

.login-card .form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.login-card .form-control {
    border-radius: 8px;
    border-color: var(--color-border);
    padding: 0.6rem 0.85rem;
    font-size: 1rem;
}

.login-card .form-control:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.12);
}

.btn-login {
    padding: 0.65rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    margin-top: 0.5rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
}

/* reCAPTCHA responsive */
.g-recaptcha {
    transform-origin: center center;
}

@media (max-width: 400px) {
    .login-card {
        padding: 1.5rem 1.25rem 1.25rem;
    }
    .brand-name {
        font-size: 1.6rem;
    }
    .g-recaptcha {
        transform: scale(0.85);
        margin: -0.5rem 0;
    }
}

/* =========================================================
   BOOTSTRAP OVERRIDES
   ========================================================= */

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

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--color-primary-dark);
    border-color: var(--color-primary-dark);
}

.btn-outline-primary {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-outline-primary:hover {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

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

/* =========================================================
   LAYOUT: SIDEBAR + TOPBAR + CONTENT
   ========================================================= */

.app-body {
    overflow-x: hidden;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    height: 100dvh;
    background: var(--color-white);
    border-right: 1px solid var(--color-border);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
    overflow: hidden;
}

.sidebar-brand {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.sidebar-brand a {
    text-decoration: none;
}

.brand-text {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.5px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.75rem 0;
    -webkit-overflow-scrolling: touch;
}

.sidebar-nav .nav {
    padding: 0;
}

.sidebar-nav .nav-item {
    margin: 0;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 0;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.sidebar-nav .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
    flex-shrink: 0;
}

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

.sidebar-nav .nav-link.active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 600;
    border-right: 3px solid var(--color-primary);
}

.nav-section {
    padding: 1.25rem 1.25rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    list-style: none;
}

/* Main wrapper */
.main-wrapper {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease;
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    gap: 0.5rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex-shrink: 1;
}

.topbar-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.sidebar-toggle {
    color: var(--color-text-muted);
    font-size: 1.2rem;
    padding: 0.25rem;
    text-decoration: none;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    color: var(--color-primary);
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown {
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
    display: inline-flex;
    align-items: center;
}

.user-dropdown:hover {
    color: var(--color-primary);
}

/* Content area */
.content-area {
    padding: 1.5rem;
    flex: 1;
    min-width: 0;
}

/* =========================================================
   STAT CARDS (Dashboard)
   ========================================================= */

.stat-card {
    background: var(--color-white);
    border-radius: 10px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--color-border);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.bg-primary-soft {
    background: rgba(44, 90, 160, 0.1);
    color: var(--color-primary);
}

.bg-success-soft {
    background: rgba(56, 161, 105, 0.1);
    color: #38a169;
}

.bg-info-soft {
    background: rgba(49, 130, 206, 0.1);
    color: #3182ce;
}

.bg-warning-soft {
    background: rgba(214, 158, 46, 0.1);
    color: #d69e2e;
}

.stat-info {
    min-width: 0;
}

.stat-info h3 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    line-height: 1;
}

.stat-info span {
    font-size: 0.82rem;
    color: var(--color-text-muted);
}

/* =========================================================
   CARDS
   ========================================================= */

.card {
    border: 1px solid var(--color-border);
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    background: var(--color-white);
    overflow: hidden;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 1.25rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
}

/* =========================================================
   TOAST NOTIFICATIONS (success — top center, 7s auto-dismiss)
   ========================================================= */

.toast-container {
    position: fixed;
    top: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    max-width: calc(100vw - 2rem);
}

.toast-notification {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.75rem 1.25rem;
    border-radius: 10px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
    animation: toastSlideDown 0.35s ease;
    min-width: 260px;
    max-width: 500px;
    word-break: break-word;
}

.toast-success {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.toast-info {
    background: #eff6ff;
    border: 1px solid #93c5fd;
    color: #1e40af;
}

.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.toast-message {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.35;
}

.toast-fade-out {
    animation: toastFadeOut 0.4s ease forwards;
}

@keyframes toastSlideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes toastFadeOut {
    from { opacity: 1; transform: translateY(0); }
    to   { opacity: 0; transform: translateY(-20px); }
}

/* =========================================================
   BLOCKING ALERT / CONFIRM (centered, overlay, no X)
   ========================================================= */

.blocking-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.blocking-overlay.visible {
    opacity: 1;
}

.blocking-alert {
    background: #fffef5;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    padding: 2rem 2rem 1.5rem;
    max-width: 440px;
    width: calc(100vw - 2rem);
    text-align: center;
    transform: scale(0.92);
    transition: transform 0.25s ease;
}

.blocking-overlay.visible .blocking-alert {
    transform: scale(1);
}

.blocking-alert-icon {
    font-size: 2.4rem;
    margin-bottom: 0.75rem;
}

.blocking-alert-message {
    font-size: 0.95rem;
    line-height: 1.5;
    color: #2d3748;
    margin-bottom: 1.5rem;
    word-break: break-word;
}

.blocking-alert-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.blocking-alert-actions .btn {
    min-width: 100px;
    font-weight: 600;
    border-radius: 8px;
    padding: 0.5rem 1.5rem;
}

/* =========================================================
   TABLES
   ========================================================= */

.table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    border-bottom-width: 1px;
    white-space: nowrap;
}

.table td {
    font-size: 0.9rem;
    vertical-align: middle;
}

/* =========================================================
   FORMS (within cards)
   ========================================================= */

.card .form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.card .form-control,
.card .form-select {
    border-radius: 8px;
    border-color: var(--color-border);
    font-size: 0.9rem;
}

.card .form-control:focus,
.card .form-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.12);
}

/* =========================================================
   RESPONSIVE — TABLET (< 992px)
   ========================================================= */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .main-wrapper {
        margin-left: 0;
    }
    .sidebar-open .sidebar {
        transform: translateX(0);
    }
    .sidebar-open .sidebar-overlay {
        display: block;
    }
    .content-area {
        padding: 1rem;
    }
    .user-dropdown {
        max-width: 180px;
    }
    .user-dropdown .badge {
        display: none;
    }
}

/* =========================================================
   RESPONSIVE — MOBILE (< 576px)
   ========================================================= */

@media (max-width: 575.98px) {
    .topbar {
        padding: 0 0.75rem;
    }
    .page-title {
        font-size: 0.95rem;
    }
    .user-dropdown {
        max-width: 140px;
        font-size: 0.8rem;
    }
    .content-area {
        padding: 0.75rem;
    }
    .stat-card {
        padding: 1rem;
    }
    .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }
    .stat-info h3 {
        font-size: 1.3rem;
    }
    .card-header {
        padding: 0.75rem 1rem;
    }
    .card-body {
        padding: 1rem;
    }
    /* Stack columns that are side-by-side in config */
    .col-6 {
        width: 100% !important;
        flex: 0 0 100% !important;
    }
}

/* =========================================================
   SIDEBAR DESKTOP COLLAPSED
   ========================================================= */

.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

.sidebar-collapsed .main-wrapper {
    margin-left: 0;
}

/* =========================================================
   SIDEBAR OVERLAY (mobile)
   ========================================================= */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1035;
    -webkit-tap-highlight-color: transparent;
}

/* =========================================================
   UTILITY — prevent horizontal overflow anywhere
   ========================================================= */

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

img,
svg,
video {
    max-width: 100%;
    height: auto;
}

/* Badge sesso femminile (rosa) - usato nella lista pazienti */
.badge.bg-pink {
    background-color: #e83e8c !important;
    color: #fff !important;
}
