@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700&display=swap');

/* === RESET & BASE === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', sans-serif;
    background: #f0f2f8;
    color: #111827;
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

/* === LAYOUT === */
.main-content {
    padding: 80px 16px 24px;
    max-width: 960px;
    margin: 0 auto;
}

.main-content.full-width {
    max-width: 100%;
    padding-top: 24px;
}

/* === NAVBAR === */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    height: 56px;
    background: #1e3a8a;
    color: #fff;
    display: flex;
    align-items: center;
    padding: 0 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.nav-brand {
    font-weight: 700;
    font-size: 18px;
    flex: 1;
}

.nav-user {
    font-size: 14px;
    margin-right: 12px;
    opacity: .85;
}

.nav-toggle {
    background: none;
    border: 1px solid rgba(255, 255, 255, .3);
    color: #fff;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 18px;
    cursor: pointer;
}

/* === SIDEBAR === */
.sidebar {
    position: fixed;
    top: 56px;
    left: -280px;
    width: 260px;
    bottom: 0;
    background: #fff;
    z-index: 150;
    box-shadow: 2px 0 16px rgba(0, 0, 0, .15);
    transition: left .25s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .3);
    z-index: 140;
}

.overlay.show {
    display: block;
}

.sidebar-header {
    padding: 20px 16px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.sidebar-name {
    font-weight: 700;
    font-size: 17px;
}

.sidebar-role {
    font-size: 12px;
    color: #6b7280;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    color: #374151;
    transition: background .15s;
}

.nav-link:hover {
    background: #f3f4f6;
}

.sidebar-logout {
    margin: 12px;
}

/* === PAGE HEADER === */
.page-header {
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 26px;
}

.page-header p {
    color: #6b7280;
    margin-top: 4px;
}

/* === CARDS === */
.card {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .07);
    margin-bottom: 16px;
}

.card h2 {
    font-size: 18px;
    margin-bottom: 16px;
    color: #1f2937;
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-10 {
    margin-top: 10px;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 11px 20px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    border: none;
    cursor: pointer;
    transition: all .17s;
    white-space: nowrap;
}

.btn-primary {
    background: #1d4ed8;
    color: #fff;
}

.btn-primary:hover {
    background: #1e40af;
}

.btn-secondary {
    background: #e5e7eb;
    color: #1f2937;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-danger {
    background: #ef4444;
    color: #fff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-back {
    background: #f3f4f6;
    color: #374151;
    font-size: 14px;
    padding: 7px 14px;
    margin-bottom: 10px;
}

.btn-full {
    width: 100%;
}

.btn-lg {
    font-size: 18px;
    padding: 15px 20px;
    margin-top: 5px;
}

.btn-sm {
    padding: 7px 12px;
    font-size: 13px;
    border-radius: 8px;
}

/* === FORMS === */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: #374151;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.text-input,
.select-input {
    width: 100%;
    padding: 11px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 9px;
    font-size: 16px;
    font-family: inherit;
    background: #fff;
    color: #111827;
    transition: border .15s;
    -webkit-appearance: none;
    appearance: none;
}

.text-input:focus,
.select-input:focus {
    outline: none;
    border-color: #1d4ed8;
}

.text-input.compact {
    min-width: 130px;
}

textarea.text-input {
    resize: vertical;
}

/* === CHECKBOX GRID === */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f9fafb;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    border: 1.5px solid #e5e7eb;
    transition: border .15s;
}

.check-label:has(input:checked) {
    border-color: #1d4ed8;
    background: #eff6ff;
}

.check-label input {
    accent-color: #1d4ed8;
    width: 16px;
    height: 16px;
}

/* === RADIO GROUP === */
.radio-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
}

.radio-label input {
    accent-color: #1d4ed8;
    width: 18px;
    height: 18px;
}

/* === COUNTER === */
.counter-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.counter-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #e5e7eb;
    border: none;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.counter-input {
    width: 70px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    border: 2px solid #d1d5db;
    border-radius: 10px;
    padding: 6px;
}

/* === TABS === */
.tab-container {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .07);
}

.tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
}

.tab {
    flex: 1;
    padding: 14px;
    font-weight: 700;
    font-size: 15px;
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    transition: all .15s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab.active {
    color: #1d4ed8;
    border-bottom-color: #1d4ed8;
}

.tab-content {
    display: none;
    padding: 20px;
}

.tab-content.active {
    display: block;
}

/* === LOTTI LIST === */
.lotti-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lot-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.lot-info {
    flex: 1;
}

.lot-info strong {
    display: block;
    font-size: 16px;
}

.lot-info small {
    color: #6b7280;
    font-size: 13px;
}

/* === INGREDIENT ROWS === */
.ing-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
}

.ing-info {
    flex: 1;
}

.ing-info strong {
    display: block;
}

.ing-info small {
    color: #6b7280;
    font-size: 13px;
}

.ing-actions {
    display: flex;
    gap: 6px;
}

.ing-recipe-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.ing-edit-row {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: flex-end;
    padding: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
}

.ing-edit-col {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ing-edit-col label {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .ing-edit-row {
        flex-direction: column;
        align-items: stretch;
    }
}

.category-header {
    font-weight: 700;
    color: #6b7280;
    font-size: 13px;
    padding: 12px 0 4px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* === GUIDE BOX (Collapsible) === */
.guide-box {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    margin-bottom: 24px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.guide-box summary {
    padding: 16px;
    font-size: 15px;
    font-weight: 700;
    color: #0369a1;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    outline: none;
    user-select: none;
}

.guide-box summary::-webkit-details-marker {
    display: none;
}

.guide-box summary::after {
    content: "▼";
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.3s ease;
}

.guide-box[open] summary::after {
    transform: rotate(180deg);
}

.guide-box summary:hover {
    background: #e0f2fe;
}

.guide-content {
    padding: 0 16px 16px 16px;
}

.guide-steps {
    margin: 0;
    padding: 0 0 0 20px;
    font-size: 14px;
    color: #075985;
    line-height: 1.6;
}

.guide-steps li {
    margin-bottom: 6px;
}

.guide-steps li strong {
    color: #0c4a6e;
}


/* === RECIPE ITEMS === */
.recipe-item {
    background: #f9fafb;
    border-radius: 12px;
    padding: 0;
    margin-bottom: 10px;
    border: 1px solid #e5e7eb;
}

.recipe-item summary {
    padding: 14px 16px;
    font-weight: 600;
    cursor: pointer;
    font-size: 16px;
}

.recipe-body {
    padding: 0 16px 16px;
}

.recipe-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.stat-box {
    background: #f3f4f6;
    border-radius: 10px;
    padding: 10px;
    font-size: 14px;
}

.stat-box strong {
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    color: #6b7280;
}

.stat-box.stat-red {
    background: #fef2f2;
}

/* === NUTRI DETAILS === */
.nutri-details {
    background: #f9fafb;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 14px;
}

.nutri-details summary {
    font-weight: 600;
    cursor: pointer;
    color: #1d4ed8;
}

/* === ALERTS === */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-weight: 600;
}

.alert-error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fee2e2;
}

.alert-success {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #dcfce7;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    color: #9ca3af;
    padding: 32px;
    font-size: 16px;
}

/* === DEPARTMENT GRID === */
.dept-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 12px;
}

.dept-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
    color: #fff;
    border-radius: 20px;
    padding: 30px 16px;
    text-align: center;
    transition: transform .15s, box-shadow .15s;
    box-shadow: 0 4px 16px rgba(30, 58, 138, .25);
    min-height: 140px;
}

.dept-card:hover,
.dept-card:active {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(30, 58, 138, .35);
}

.dept-emoji {
    font-size: 48px;
}

.dept-name {
    font-size: 22px;
    font-weight: 700;
    margin-top: 10px;
    letter-spacing: .5px;
}

/* === LOGIN === */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f8;
    padding: 16px;
}

.login-card {
    background: #fff;
    border-radius: 24px;
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, .10);
}

.login-logo {
    text-align: center;
    font-size: 56px;
}

.login-title {
    text-align: center;
    font-size: 26px;
    font-weight: 700;
    margin: 8px 0 4px;
}

.login-sub {
    text-align: center;
    color: #6b7280;
    margin-bottom: 20px;
}

/* PIN Display */
.pin-display {
    text-align: center;
    font-size: 44px;
    letter-spacing: 14px;
    background: #1e3a8a;
    color: #00ff99;
    border-radius: 14px;
    padding: 16px 8px;
    margin-bottom: 16px;
    min-height: 76px;
}

/* PIN Grid — 3 colonne garantite con CSS Grid nativo */
.pin-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 10px;
    width: 100%;
}

.pin-btn {
    background: #1d4ed8;
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 28px;
    font-weight: 700;
    padding: 18px 0;
    cursor: pointer;
    touch-action: manipulation;
    transition: background .12s, transform .08s;
    -webkit-tap-highlight-color: transparent;
}

.pin-btn:active {
    background: #1e40af;
    transform: scale(.95);
}

.pin-clear {
    background: #ef4444 !important;
}

.pin-ok {
    background: #16a34a !important;
}

/* === ETICHETTA === */
.etichetta-wrap {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.etichetta-preview {
    background: #fff;
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .07);
}

.etichetta-img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.print-controls {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .07);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.print-info {
    font-size: 17px;
    font-weight: 600;
}

/* === RESPONSIVE === */
@media (min-width: 640px) {
    .etichetta-wrap {
        flex-direction: row;
        align-items: flex-start;
    }

    .etichetta-preview {
        flex: 2;
    }

    .print-controls {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .dept-grid {
        gap: 12px;
    }

    .dept-emoji {
        font-size: 38px;
    }

    .dept-name {
        font-size: 18px;
    }

    h1 {
        font-size: 22px;
    }

    .btn-lg {
        font-size: 16px;
    }
}