/* Beer Tap Dashboard — Dark theme */

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: #0D0D0D;
    color: #F5ECD7;
    font-family: -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.5;
}

header {
    padding: 20px 24px;
    border-bottom: 1px solid #2A2217;
}

header h1 {
    font-size: 26px;
    color: #F5A623;
    letter-spacing: 1px;
}

/* Statistiche globali */
.stats-global {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 20px 24px;
}

.stat-card {
    background: #131310;
    border: 1px solid #2A2217;
    border-radius: 10px;
    padding: 18px 16px;
    text-align: center;
}

.stat-card.highlight {
    border-color: #F5A623;
}

.stat-card.today {
    background: #1A1608;
}

.stat-value {
    display: block;
    font-size: 26px;
    font-weight: 700;
    color: #F5ECD7;
    margin-bottom: 6px;
}

.stat-card.highlight .stat-value {
    color: #F5A623;
}

.stat-label {
    display: block;
    font-size: 12px;
    color: #8A7B5A;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
}

/* Terminali */
.terminals {
    padding: 20px 24px;
}

.terminals h2 {
    font-size: 18px;
    color: #F5A623;
    margin-bottom: 16px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
}

.empty {
    color: #8A7B5A;
    font-size: 15px;
    text-align: center;
    padding: 40px;
}

.terminal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.terminal-card {
    background: #131310;
    border: 1px solid #2A2217;
    border-radius: 10px;
    padding: 18px;
}

.terminal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.terminal-id {
    font-size: 22px;
    font-weight: 700;
    color: #F5A623;
}

.sync-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.sync-dot.online { background: #00E676; }
.sync-dot.warning { background: #FFD600; }
.sync-dot.offline { background: #FF1744; }
.sync-dot.never { background: #6B5D3F; }

.terminal-desc {
    font-size: 15px;
    color: #8A7B5A;
    margin-bottom: 6px;
}

.terminal-beer {
    font-size: 14px;
    color: #F5ECD7;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #2A2217;
}

.terminal-stats {
    margin-bottom: 12px;
}

.ts-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
}

.ts-label {
    font-size: 12px;
    color: #8A7B5A;
    letter-spacing: 1px;
    width: 55px;
    flex-shrink: 0;
    font-weight: 600;
}

.ts-value {
    font-size: 20px;
    font-weight: 700;
    color: #F5A623;
    width: 110px;
    flex-shrink: 0;
}

.ts-detail {
    font-size: 13px;
    color: #8A7B5A;
}

.terminal-sync {
    font-size: 12px;
    color: #5A4D35;
    border-top: 1px solid #2A2217;
    padding-top: 8px;
}

/* Transazioni per terminale */
.terminal-txs {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #2A2217;
}

.txs-title {
    display: block;
    font-size: 12px;
    color: #8A7B5A;
    letter-spacing: 2px;
    margin-bottom: 8px;
    font-weight: 600;
}

.tx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tx-table th {
    text-align: left;
    font-size: 11px;
    color: #8A7B5A;
    letter-spacing: 1px;
    padding: 6px 8px;
    border-bottom: 1px solid #2A2217;
    font-weight: 600;
}

.tx-table td {
    padding: 6px 8px;
    color: #F5ECD7;
    border-bottom: 1px solid #1A1608;
}

.tx-table td:nth-child(3) {
    color: #F5A623;
    font-weight: 700;
}

.tx-status {
    font-size: 11px;
    letter-spacing: 1px;
    font-weight: 700;
}

.status-paid { color: #00E676; }
.status-failed { color: #FF1744; }
.status-pending { color: #FFD600; }
.status-other { color: #90CAF9; }

/* Footer */
footer {
    padding: 20px 24px;
    text-align: center;
    border-top: 1px solid #2A2217;
    margin-top: 24px;
}

footer p {
    font-size: 13px;
    color: #5A4D35;
    letter-spacing: 1px;
}

/* Header con link */
.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-link, .config-link {
    color: #F5A623;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 8px 16px;
    border: 1px solid #F5A623;
    border-radius: 6px;
    transition: background 0.2s;
}

.back-link:hover, .config-link:hover {
    background: #F5A623;
    color: #0D0D0D;
}

/* Config section (read-only nella dashboard) */
.config-section {
    padding: 20px 24px;
}

.config-section h2 {
    font-size: 18px;
    color: #F5A623;
    margin-bottom: 16px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.config-item {
    background: #131310;
    border: 1px solid #2A2217;
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}

.config-item.highlight {
    border-color: #F5A623;
}

.config-label {
    display: block;
    font-size: 11px;
    color: #8A7B5A;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
    font-weight: 600;
}

.config-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #F5ECD7;
}

.config-item.highlight .config-value {
    color: #F5A623;
}

/* Config form page */
.config-form-section {
    padding: 20px 24px;
    max-width: 640px;
    margin: 0 auto;
}

.config-form .form-group {
    background: #131310;
    border: 1px solid #2A2217;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.config-form .form-group h2 {
    font-size: 16px;
    color: #F5A623;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 16px;
    font-weight: 600;
}

.form-hint {
    font-size: 13px;
    color: #8A7B5A;
    margin-bottom: 14px;
    line-height: 1.4;
}

.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row label {
    font-size: 14px;
    color: #B0A080;
    font-weight: 500;
}

.form-row input {
    width: 160px;
    padding: 10px 14px;
    background: #0D0D0D;
    border: 1px solid #3A3020;
    border-radius: 6px;
    color: #F5ECD7;
    font-size: 16px;
    font-weight: 600;
    text-align: right;
    outline: none;
    transition: border-color 0.2s;
}

.form-row input:focus {
    border-color: #F5A623;
}

/* Riepilogo */
.form-group.summary {
    border-color: #F5A623;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 15px;
    color: #B0A080;
    border-bottom: 1px solid #1A1608;
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row span:last-child {
    color: #F5ECD7;
    font-weight: 600;
}

.summary-row.total {
    border-top: 2px solid #F5A623;
    margin-top: 4px;
    padding-top: 12px;
}

.summary-row.total span {
    font-size: 18px;
    color: #F5A623;
    font-weight: 700;
}

/* Form buttons */
.form-actions {
    display: flex;
    gap: 14px;
    margin-top: 8px;
}

.btn-save {
    flex: 1;
    padding: 14px;
    background: #F5A623;
    color: #0D0D0D;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-save:hover {
    background: #FFBB33;
}

.btn-cancel {
    padding: 14px 24px;
    color: #B0A080;
    border: 1px solid #3A3020;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    text-decoration: none;
    text-align: center;
    transition: border-color 0.2s;
}

.btn-cancel:hover {
    border-color: #F5A623;
    color: #F5A623;
}

/* Toast notification */
.toast {
    margin: 16px 24px;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    text-align: center;
    transition: opacity 0.3s;
}

.toast.success {
    background: #0A2E14;
    border: 1px solid #00C853;
    color: #00E676;
}

/* Hardware status per terminale */
.terminal-hw {
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #2A2217;
}

.hw-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.hw-label {
    font-size: 12px;
    color: #8A7B5A;
    font-weight: 600;
    letter-spacing: 1px;
    width: 95px;
}

.hw-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.hw-dot.hw-on { background: #00E676; box-shadow: 0 0 6px #00E67680; }
.hw-dot.hw-off { background: #FF1744; }

.hw-value {
    font-size: 12px;
    color: #B0A080;
}

/* Temperature */
.hw-temps {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.temp-box {
    flex: 1;
    background: #0D0D0D;
    border: 1px solid #2A2217;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}

.temp-label {
    display: block;
    font-size: 10px;
    color: #8A7B5A;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
    font-weight: 600;
}

.temp-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
}

.temp-ok { color: #00E676; }
.temp-warn { color: #FFD600; }
.temp-hot { color: #FF1744; }

/* Ingressi digitali */
.hw-inputs {
    display: flex;
    gap: 8px;
}

.input-box {
    flex: 1;
    border-radius: 6px;
    padding: 6px 8px;
    text-align: center;
    border: 1px solid;
}

.input-box.input-closed {
    background: #0A2E14;
    border-color: #00C853;
}

.input-box.input-open {
    background: #2E0A0A;
    border-color: #FF1744;
}

.input-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
}

.input-closed .input-label { color: #00E676; }
.input-open .input-label { color: #FF1744; }

/* Tank level */
.tank-level {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 2px solid;
    margin-bottom: 10px;
}

.tank-level.tank-ok {
    background: #0A2E14;
    border-color: #00C853;
}

.tank-level.tank-low {
    background: #2E1A0A;
    border-color: #FF9100;
    animation: tank-pulse 1.5s ease-in-out infinite;
}

.tank-level.tank-empty {
    background: #2E0A0A;
    border-color: #FF1744;
}

.tank-icon { font-size: 20px; }

.tank-info { display: flex; flex-direction: column; }

.tank-value {
    font-size: 20px;
    font-weight: 700;
}

.tank-ok .tank-value { color: #00E676; }
.tank-low .tank-value { color: #FF9100; }
.tank-empty .tank-value { color: #FF1744; }

.tank-label {
    font-size: 10px;
    color: #8A7B5A;
    letter-spacing: 1px;
    font-weight: 600;
}

.tank-warning {
    margin-left: auto;
    font-size: 12px;
    font-weight: 700;
    color: #FF9100;
    letter-spacing: 1px;
    animation: tank-blink 0.8s ease-in-out infinite;
}

@keyframes tank-pulse {
    0%, 100% { box-shadow: 0 0 4px #FF910040; }
    50% { box-shadow: 0 0 16px #FF910080; }
}

@keyframes tank-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Sezione Cambio Tank (fuori dal refresh) */
.tank-section {
    padding: 20px 24px;
}

.tank-section h2 {
    font-size: 18px;
    color: #F5A623;
    margin-bottom: 16px;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 600;
}

.tank-form-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.tank-form-card {
    background: #131310;
    border: 1px solid #2A2217;
    border-radius: 10px;
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tank-form-id {
    color: #F5A623;
    font-weight: 700;
    font-size: 16px;
}

.tank-form-desc {
    color: #8A7B5A;
    font-size: 13px;
}

/* Cambio tank inputs */

.tank-input {
    flex: 1;
    padding: 8px 12px;
    background: #0D0D0D;
    border: 1px solid #3A3020;
    border-radius: 6px;
    color: #F5ECD7;
    font-size: 14px;
    font-weight: 600;
    text-align: right;
    outline: none;
    transition: border-color 0.3s;
}

.tank-input:focus {
    border-color: #F5A623;
}

.tank-btn {
    padding: 8px 16px;
    background: #F5A623;
    color: #0D0D0D;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}

.tank-btn:hover {
    background: #FFBB33;
}

/* Relay spillatura */
.pour-relay-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 2px solid;
}

.pour-relay-box.pour-active {
    background: #0A2E14;
    border-color: #00C853;
    animation: pour-pulse 1s ease-in-out infinite;
}

.pour-relay-box.pour-idle {
    background: #1A1608;
    border-color: #2A2217;
}

.pour-relay-icon {
    font-size: 18px;
}

.pour-active .pour-relay-icon { color: #00E676; }
.pour-idle .pour-relay-icon { color: #5A4D35; }

.pour-relay-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 2px;
}

.pour-active .pour-relay-label { color: #00E676; }
.pour-idle .pour-relay-label { color: #8A7B5A; }

.pour-relay-status {
    margin-left: auto;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
}

.pour-active .pour-relay-status { color: #00E676; }
.pour-idle .pour-relay-status { color: #5A4D35; }

@keyframes pour-pulse {
    0%, 100% { box-shadow: 0 0 4px #00C85340; }
    50% { box-shadow: 0 0 16px #00C85380; }
}

/* Responsive */
@media (max-width: 768px) {
    .stats-global {
        grid-template-columns: repeat(2, 1fr);
    }
    .terminal-grid {
        grid-template-columns: 1fr;
    }
}
