:root {
    --bg: #05070d;
    --card-bg: #0c1019;
    --card-bg-soft: #111827;
    --accent: #6366f1;         /* indaco soft */
    --accent-soft: rgba(99, 102, 241, 0.3);
    --text-main: #f9fafb;
    --text-muted: #9ca3af;
    --border-subtle: #1f2933;
    --danger: #f97373;
    --success: #4ade80;
    --radius-lg: 16px;
    --shadow-soft: 0 16px 30px rgba(0, 0, 0, 0.75);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
        "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #111827 0, #020617 60%);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-x: hidden;
    transition: padding 0.35s ease, align-items 0.35s ease;
}

body.logged-in {
    align-items: flex-start;
    padding: 24px;
}

#app {
    width: 100%;
    max-width: 1200px;
}

h1,
h2 {
    margin: 0;
}

/* -------- LOGIN CARD -------- */

#loginView {
    position: relative;
    margin: 0 auto 20px auto;
    max-width: 420px;
    border-radius: var(--radius-lg);
    padding: 1px;
    background: linear-gradient(135deg, rgba(17, 24, 39, 1), rgba(15, 23, 42, 1));
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease, max-width 0.3s ease;
}

#loginView:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.85);
}

body.logged-in #loginView {
    max-width: 100%;
    margin-bottom: 16px;
}

#loginInner {
    background: var(--card-bg);
    padding: 18px 18px 14px;
    border-radius: calc(var(--radius-lg) - 1px);
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

body.logged-in #loginInner {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.4fr);
    align-items: center;
    padding: 16px 18px;
}

/* Brand */

.brand-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: radial-gradient(circle, var(--accent) 0, #1f2937 62%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #020617;
    font-size: 16px;
    font-weight: 700;
}

.brand-text-main {
    font-size: 18px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-main);
}

.brand-text-sub {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
}

.login-main-title {
    font-size: 22px;
    font-weight: 600;
    margin-top: 10px;
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

/* FORM */

.row {
    margin-bottom: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.input-shell {
    position: relative;
}

.report-top-products {
    margin-top: 8px;
    max-height: 260px;
    overflow-y: auto;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.nav-link:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
select {
    width: 100%;
    padding: 9px 10px 9px 32px;
    border-radius: 999px;
    border: 1px solid #1f2937;
    background: #020617;
    color: var(--text-main);
    font-size: 13px;
    outline: none;
    transition: border 0.16s ease, box-shadow 0.16s ease, background 0.16s ease,
        transform 0.12s ease;
}

input::placeholder {
    color: rgba(148, 163, 184, 0.9);
}

input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-soft);
    background: #020617;
    transform: translateY(-1px);
}

.input-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    opacity: 0.65;
}

/* BUTTONS */

button {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease,
        border 0.14s ease, color 0.14s ease, opacity 0.12s ease;
    white-space: nowrap;
    background: none;
}

button:active {
    transform: translateY(0) scale(0.97);
    opacity: 0.95;
}

.btn-primary {
    background: var(--accent);
    border-color: transparent;
    color: #020617;
    font-weight: 600;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.9);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 26px rgba(15, 23, 42, 0.95);
}

.btn-secondary {
    background: #020617;
    border-color: #1f2937;
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #020617;
    border-color: #374151;
    transform: translateY(-1px);
}

/* AZIONI AUTH */

.auth-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.auth-actions-right {
    margin-left: auto;
    display: flex;
    gap: 6px;
    align-items: center;
}

#logoutBtn {
    display: none;
}

/* STATUS */

.status {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
    opacity: 0.95;
}

.status.error {
    color: var(--danger);
}

.status.success {
    color: var(--success);
}

#loggedUserInfo {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ---------- POS VIEW ---------- */

#posView {
    display: none;
}

/* BARRA CONTROLLI */

.controls-panel {
    background: var(--card-bg-soft);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.controls-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 150px;
}

.controls-group label {
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--text-muted);
}

.controls-group select {
    padding-inline-start: 10px;
}

/* LAYOUT PRINCIPALE */

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1.2fr);
    gap: 18px;
}

/* PANNELLI POS */

.panel-pos {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 14px 14px 12px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    min-height: 260px;
}

.panel-pos h2 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.panel-sub {
    font-size: 11px;
    color: var(--text-muted);
}

/* CATEGORIE */

.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
    max-height: 72px;
    overflow-y: auto;
    padding-right: 2px;
}

.category-btn {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid #1f2937;
    background: #020617;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease,
        transform 0.12s ease;
}

.category-btn:hover {
    border-color: #374151;
    color: var(--text-main);
}

.category-btn.active {
    background: #111827;
    border-color: var(--accent);
    color: var(--text-main);
}

/* PRODotti */

.products {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 360px;
    overflow-y: auto;
    padding-right: 4px;
}

.products::-webkit-scrollbar,
.categories::-webkit-scrollbar {
    width: 6px;
}

.products::-webkit-scrollbar-track,
.categories::-webkit-scrollbar-track {
    background: transparent;
}

.products::-webkit-scrollbar-thumb,
.categories::-webkit-scrollbar-thumb {
    background: #1f2937;
    border-radius: 999px;
}

.product-btn {
    flex: 0 0 calc(33.33% - 8px);
    padding: 8px;
    border-radius: 10px;
    border: 1px solid #1f2937;
    background: #020617;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: var(--text-main);
    transition: transform 0.12s ease, box-shadow 0.12s ease, border 0.12s ease,
        background 0.12s ease;
}

.product-btn:hover {
    transform: translateY(-1px);
    border-color: #374151;
    background: #050816;
}

.product-name {
    font-weight: 500;
    display: block;
    margin-bottom: 2px;
}

.product-price {
    font-size: 12px;
    color: var(--text-muted);
}

/* TABELLA CARRELLO */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 4px;
}

th,
td {
    padding: 6px;
    border-bottom: 1px solid #1f2937;
    text-align: left;
}

th {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 12px;
}

tbody tr:hover {
    background: #050816;
}

tfoot td {
    font-weight: 600;
    font-size: 13px;
}

/* Q.TÀ */

.qty-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.qty-btn {
    padding: 2px 7px;
    font-size: 12px;
    border-radius: 999px;
    border: 1px solid #374151;
    background: #020617;
    color: var(--text-main);
    cursor: pointer;
}

.qty-btn:hover {
    background: #050816;
}

/* bottone remove in ultima colonna */

tbody td:last-child button {
    padding: 3px 8px;
    border-radius: 999px;
    background: #111827;
    border: 1px solid #4b5563;
    color: #e5e7eb;
    font-size: 11px;
}

tbody td:last-child button:hover {
    background: #b91c1c;
    border-color: #fecaca;
    color: #fee2e2;
}

/* AZIONI CARRELLO */

.cart-actions {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-muted);
}

#lastOrderInfo {
    opacity: 0.9;
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 900px) {
    body.logged-in {
        align-items: flex-start;
    }

    #loginInner {
        grid-template-columns: 1fr;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .product-btn {
        flex: 0 0 calc(50% - 8px);
    }
}

@media (max-width: 600px) {
    body {
        padding: 16px;
    }

    .controls-panel {
        flex-direction: column;
        align-items: stretch;
    }

    .controls-group {
        width: 100%;
    }

    .cart-actions {
        flex-direction: column-reverse;
        align-items: flex-start;
    }
}

/* ---------- HEADER APP CON LOGO ---------- */

.app-header {
    display: flex;
    justify-content: center;
    align-items: center;

    /* la larghezza segue il contenuto */
    width: fit-content;

    padding: 1.5rem 2rem;
    margin: 0 auto 24px auto; /* centrato, con spazio sotto */

    border-radius: 999px;
    background: var(--card-bg-soft);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.7);
}

.app-logo {
    /* logo più grande */
    height: 50px;
    max-width: 280px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
}

/* su schermi piccoli, riduciamo un filo */
@media (max-width: 600px) {
    .app-header {
        padding: 8px 18px;
        margin-bottom: 18px;
        box-shadow: 0 10px 22px rgba(0, 0, 0, 0.75);
    }

    .app-logo {
        height: 52px;
        max-width: 220px;
    }
}

/* ---------- NAVBAR TABLET ---------- */

.top-nav {
    background: var(--card-bg-soft);
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.top-nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.top-nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-nav-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--text-muted);
}

.top-nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Utente in alto a destra */
.top-nav-user {
    font-size: 12px;
    color: var(--text-muted);
}

/* Logout nella nav, un filo più compatto */
.btn-logout-nav {
    padding-inline: 10px;
}

/* HAMBURGER */

.nav-burger {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid #1f2937;
    background: #020617;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.nav-burger span {
    display: block;
    width: 14px;
    height: 2px;
    border-radius: 999px;
    background: #e5e7eb;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.nav-burger span + span {
    margin-top: 4px;
}

/* MENU LINK */

.nav-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.nav-link {
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid #1f2937;
    background: #020617;
    font-size: 13px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease,
        transform 0.12s ease;
}

.nav-link:hover {
    border-color: #374151;
    color: var(--text-main);
}

.nav-link.active {
    background: #111827;
    border-color: var(--accent);
    color: var(--text-main);
}

/* SEZIONI */

.app-section {
    display: none;
}

.app-section-active {
    display: block;
}

/* testo placeholder config */

.config-placeholder {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* NAV su tablet/mobile: menu a comparsa */

@media (max-width: 900px) {
    .nav-menu {
        display: none;
        flex-direction: column;
        padding-top: 4px;
    }

    .nav-menu.open {
        display: flex;
    }
}

/* ---------- GRID SEZIONI (CONFIG / REPORT) ---------- */

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

/* TESTO PLACEHOLDER CONFIG/REPORT */

.config-placeholder {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
    margin-bottom: 12px;
}

/* BOTTONI CONFIG AZIONI */

.config-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.config-btn {
    font-size: 13px;
}

/* REPORT: FILTRI E METRICHE */

.report-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
    margin-bottom: 12px;
}

.report-filters .row {
    margin-bottom: 0;
    min-width: 150px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.metric-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.metric-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
}

.metric-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.panel-subtitle {
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-muted);
}

/* RESPONSIVE PICCOLO */

@media (max-width: 600px) {
    .report-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .report-filters .row {
        min-width: 100%;
    }
}

/* ---------- CONFIGURAZIONE: INFO BAR + TAB ---------- */

.config-bar-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.config-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.config-tab {
    padding: 5px 11px;
    border-radius: 999px;
    border: 1px solid #1f2937;
    background: #020617;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease,
        transform 0.12s ease;
}

.config-tab:hover {
    border-color: #374151;
    color: var(--text-main);
}

.config-tab.active {
    background: #111827;
    border-color: var(--accent);
    color: var(--text-main);
}

/* VIEW PRODOTTI / CATEGORIE */

.config-view {
    display: none;
}

.config-view-active {
    display: block;
}

/* FORM CONFIG */

.config-form {
    margin-bottom: 10px;
    padding: 10px 10px 8px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid #1f2937;
}

.row-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.row-inline .row {
    flex: 1 1 160px;
}

.config-form-actions {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

/* TABELLA PRODOTTI (CONFIG) */

.config-table-wrapper {
    max-height: 260px;
    overflow-y: auto;
}

.config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.config-table th,
.config-table td {
    padding: 6px;
    border-bottom: 1px solid #1f2937;
    text-align: left;
}

.config-table th {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 12px;
}

/* LISTA CATEGORIE */

.config-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 220px;
    overflow-y: auto;
}

.config-category-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #020617;
    border: 1px solid #1f2937;
    font-size: 12px;
    color: var(--text-main);
}

.config-category-pill button {
    padding: 2px 6px;
    font-size: 11px;
}

/* mobile: form più in colonna */

@media (max-width: 600px) {
    .row-inline {
        flex-direction: column;
    }
}