/* ============================================================
   OxyBatch Manager — Stylesheet
   Medical-grade UI · White/Blue · Clean & Professional
   ============================================================ */

:root {
    /* ── Palette ─────────────────────────────────────────── */
    --navy:        #0B1D3A;
    --navy-light:  #122B52;
    --blue:        #1565C0;
    --blue-mid:    #1E88E5;
    --blue-light:  #42A5F5;
    --blue-pale:   #E3F2FD;
    --cyan:        #00ACC1;
    --teal:        #009688;

    --white:       #FFFFFF;
    --gray-50:     #F8FAFC;
    --gray-100:    #F1F5F9;
    --gray-200:    #E2E8F0;
    --gray-300:    #CBD5E1;
    --gray-400:    #94A3B8;
    --gray-500:    #64748B;
    --gray-600:    #475569;
    --gray-700:    #334155;
    --gray-900:    #0F172A;

    --success:     #16A34A;
    --warning:     #D97706;
    --danger:      #DC2626;

    /* ── Typography ──────────────────────────────────────── */
    --font-display: 'Outfit', sans-serif;
    --font-body:    'DM Sans', sans-serif;

    --text-xs:   clamp(0.7rem,  1.5vw, 0.78rem);
    --text-sm:   clamp(0.8rem,  1.8vw, 0.875rem);
    --text-base: clamp(0.9rem,  2vw,   1rem);
    --text-lg:   clamp(1rem,    2.5vw, 1.25rem);
    --text-xl:   clamp(1.25rem, 3vw,   1.5rem);
    --text-2xl:  clamp(1.5rem,  4vw,   2rem);

    /* ── Spacing & Radius ────────────────────────────────── */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    /* ── Transitions ─────────────────────────────────────── */
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --duration: 0.25s;
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--gray-700);
    background: var(--gray-50);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--navy);
    font-weight: 700;
}

/* ── Navbar ──────────────────────────────────────────────── */
.navbar {
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
    padding: 0.6rem 0;
    box-shadow: 0 2px 20px rgba(11, 29, 58, 0.25);
    z-index: 1030;
}

.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.12);
    border-radius: 8px;
    font-size: 1.2rem;
    color: var(--blue-light);
    border: 1px solid rgba(255,255,255,0.08);
}

.brand-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--white);
    letter-spacing: -0.02em;
}

.navbar .nav-link {
    padding-left: 0.6rem !important;
    padding-right: 0.6rem !important;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
    font-size: var(--text-sm);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    transition: all var(--duration) var(--ease-out);
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: var(--white);
    background: rgba(255,255,255,0.1);
}

.navbar .nav-link i { margin-right: 0.35rem; }

.navbar-toggler {
    border: 1px solid rgba(255,255,255,0.2);
    color: var(--white);
    font-size: 1.3rem;
    padding: 0.3rem 0.6rem;
}

.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: rgba(255,255,255,0.85);
    font-size: var(--text-sm);
    font-weight: 500;
}

.role-tag {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    background: var(--blue);
    color: var(--white);
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1440px;
    margin: 0 auto;
    width: 100%;
}

/* ── Cards ───────────────────────────────────────────────── */
.card-oxy {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
    transition: box-shadow var(--duration) var(--ease-out);
    overflow: hidden;
}

.card-oxy:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.06);
}

.card-header-oxy {
    background: linear-gradient(135deg, var(--blue-pale) 0%, var(--gray-100) 100%);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.card-header-oxy h2,
.card-header-oxy h3 {
    margin: 0;
    font-size: var(--text-lg);
}

.card-header-oxy i {
    color: var(--blue);
    font-size: 1.3rem;
}

.card-body-oxy {
    padding: 1.5rem;
}

/* ── Form Styling ────────────────────────────────────────── */
.form-label {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--gray-600);
    margin-bottom: 0.3rem;
}

.form-control, .form-select {
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    padding: 0.55rem 0.85rem;
    transition: border-color var(--duration) var(--ease-out),
                box-shadow var(--duration) var(--ease-out);
}

.form-control:focus, .form-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.15);
}

.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* ── Table Riempimenti ───────────────────────────────────── */
.table-batch {
    font-size: var(--text-sm);
    margin-bottom: 0;
}

.table-batch thead {
    background: var(--navy);
    color: var(--white);
}

.table-batch thead th {
    font-weight: 600;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 0.6rem;
    border: none;
    white-space: nowrap;
    vertical-align: middle;
    text-align: center;
}

.table-batch tbody td {
    padding: 0.5rem 0.6rem;
    vertical-align: middle;
    border-color: var(--gray-200);
    text-align: center;
}

.table-batch tbody tr {
    transition: background var(--duration) var(--ease-out);
}

.table-batch tbody tr:hover {
    background: var(--blue-pale);
}

.table-batch .form-check-input {
    width: 1.3rem;
    height: 1.3rem;
    cursor: pointer;
    border: 2px solid var(--gray-400);
}

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

.table-batch .matricola-input {
    width: 130px;
    font-family: 'DM Sans', monospace;
    font-weight: 600;
    text-transform: uppercase;
    text-align: center;
}

.table-batch .volume-input {
    width: 65px;
    text-align: center;
}

.table-batch .rampa-select {
    width: 75px;
}

.row-scarto td {
    background: rgba(220, 38, 38, 0.06) !important;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary-oxy {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 100%);
    color: var(--white);
    border: none;
    font-weight: 600;
    font-size: var(--text-sm);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--duration) var(--ease-out);
    box-shadow: 0 2px 6px rgba(21, 101, 192, 0.3);
}

.btn-primary-oxy:hover {
    background: linear-gradient(135deg, var(--blue-mid) 0%, var(--blue) 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(21, 101, 192, 0.35);
    color: var(--white);
}

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

.btn-danger-oxy {
    background: var(--danger);
    color: var(--white);
    border: none;
    font-weight: 600;
    font-size: var(--text-sm);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 6px rgba(220, 38, 38, 0.25);
}

.btn-success-oxy {
    background: linear-gradient(135deg, var(--success) 0%, var(--teal) 100%);
    color: var(--white);
    border: none;
    font-weight: 600;
    font-size: var(--text-sm);
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25);
}

/* ── Badge Stato ─────────────────────────────────────────── */
.badge-aperto {
    background: rgba(217, 119, 6, 0.12);
    color: var(--warning);
    font-weight: 700;
    font-size: var(--text-xs);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
}

.badge-chiuso {
    background: rgba(22, 163, 74, 0.12);
    color: var(--success);
    font-weight: 700;
    font-size: var(--text-xs);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
}

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
}

.stat-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px; height: 52px;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--blue-pale); color: var(--blue); }
.stat-icon.green { background: rgba(22,163,74,0.1); color: var(--success); }
.stat-icon.amber { background: rgba(217,119,6,0.1); color: var(--warning); }
.stat-icon.cyan { background: rgba(0,172,193,0.1); color: var(--cyan); }

.stat-value {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 800;
    color: var(--navy);
    line-height: 1;
}

.stat-label {
    font-size: var(--text-xs);
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Section Headers ─────────────────────────────────────── */
.section-title {
    font-size: var(--text-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--blue-pale);
    margin-bottom: 1rem;
}

.section-title i { color: var(--blue); }

/* ── Alert Custom ────────────────────────────────────────── */
.alert-anomalia {
    background: rgba(220, 38, 38, 0.06);
    border-left: 4px solid var(--danger);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: var(--text-sm);
    color: var(--danger);
    font-weight: 500;
}

/* ── Login Page ──────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--navy) 0%, var(--navy-light) 40%, var(--blue) 100%);
    padding: 2rem;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
}

.login-card .brand-icon {
    width: 56px; height: 56px;
    font-size: 1.6rem;
    background: var(--blue-pale);
    color: var(--blue);
    border: none;
    margin: 0 auto 1rem;
    display: flex;
}

.login-card h1 {
    text-align: center;
    font-size: var(--text-xl);
    margin-bottom: 0.3rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: var(--text-sm);
    margin-bottom: 1.5rem;
}

/* ── Ricerca ─────────────────────────────────────────────── */
.search-box {
    position: relative;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.search-box input {
    padding-left: 2.8rem;
}

/* ── Timeline Bombola ────────────────────────────────────── */
.timeline-item {
    position: relative;
    padding-left: 2.5rem;
    padding-bottom: 1.5rem;
    border-left: 2px solid var(--gray-200);
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px; top: 4px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--blue);
    border: 2px solid var(--white);
}

.timeline-item:last-child {
    border-left-color: transparent;
}

/* ── Footer ──────────────────────────────────────────────── */
.app-footer {
    background: var(--gray-100);
    border-top: 1px solid var(--gray-200);
    padding: 0.8rem 0;
    font-size: var(--text-xs);
    color: var(--gray-500);
}

/* ── Animations ──────────────────────────────────────────── */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeUp 0.5s var(--ease-out) both;
}

.animate-in:nth-child(2) { animation-delay: 0.08s; }
.animate-in:nth-child(3) { animation-delay: 0.16s; }
.animate-in:nth-child(4) { animation-delay: 0.24s; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .main-content { padding: 1rem; }
    .card-body-oxy { padding: 1rem; }
    .table-batch { font-size: 0.75rem; }
    .table-batch .matricola-input { width: 100px; }
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
    .navbar, .app-footer, .btn, .no-print { display: none !important; }
    body { background: white; }
    .card-oxy { box-shadow: none; border: 1px solid #ccc; }
}
