* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fa;
    color: #333;
    padding: 12px;
}
.container {
    max-width: 1700px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
    flex-shrink: 0;
}
header h1 { font-weight: 300; color: #2c3e50; font-size: 1.5rem; }
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    flex-wrap: wrap;
}
.user-info span { font-weight: 600; }
.btn-logout {
    background: #e74c3c;
    color: white;
    padding: 6px 14px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.2s;
}
.btn-logout:hover { background: #c0392b; }
.btn-help {
    background: #2ecc71;
    color: white;
    padding: 6px 14px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn-help:hover { background: #27ae60; }

.alert {
    padding: 10px 16px;
    border-radius: 4px;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.alert.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.dropdown-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.06);
    flex-shrink: 0;
}
.dropdown-bar label {
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 6px;
}
.dropdown-bar select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    background: white;
    flex: 1;
    min-width: 180px;
    cursor: pointer;
}
.dropdown-bar select:focus {
    outline: none;
    border-color: #3498db;
}
.dropdown-bar .btn-secondary {
    background: #ecf0f1;
    color: #555;
    border: 1px solid #ddd;
    padding: 8px 18px;
    border-radius: 4px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.dropdown-bar .btn-secondary:hover { background: #d5dbdb; }

.form-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
}
h2 {
    font-weight: 400;
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #2c3e50;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-bottom: 12px;
}
.form-group {
    flex: 1 1 180px;
    min-width: 150px;
}
.form-group.full-width { flex: 1 1 100%; }
label {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.85rem;
    color: #555;
}
.required { color: #e74c3c; }
input[type="text"], input[type="time"], select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.95rem;
    background: #fff;
}
input:focus, select:focus { border-color: #3498db; outline: none; }

.time-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.time-item {
    display: flex;
    align-items: center;
    gap: 6px;
}
.time-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #555;
    min-width: 24px;
}
.time-item input[type="time"] {
    width: auto;
    flex: 0 1 120px;
    padding: 6px 10px;
    font-size: 0.9rem;
}

.sliders-container {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 8px 0;
    margin-top: 4px;
    width: 100%;
    overflow-x: auto;
}
.slider-item {
    flex: 1 1 0;
    min-width: 75px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 10px 6px;
    border: 2px solid #e8ecf0;
}
.slider-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 4px;
    padding: 0 2px;
}
.canale-badge {
    font-weight: 700;
    font-size: 0.7rem;
    color: #3498db;
    background: #ebf5fb;
    padding: 2px 8px;
    border-radius: 10px;
}
.tempo-badge {
    font-weight: 600;
    font-size: 0.7rem;
    color: #2c3e50;
    background: #ecf0f1;
    padding: 2px 8px;
    border-radius: 10px;
}
.slider-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 8px;
    background: #ddd;
    border-radius: 5px;
    outline: none;
    margin: 6px 0;
}
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
}
.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    border: none;
}
.slider-value {
    width: 50px;
    text-align: center;
    padding: 3px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.85rem;
}

@media (min-width: 768px) {
    .slider-wrapper {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 180px;
    }
    .slider {
        -webkit-appearance: slider-vertical;
        appearance: slider-vertical;
        width: 6px;
        height: 130px;
        margin: 0 auto;
        background: #ddd;
    }
    .slider::-webkit-slider-thumb {
        -webkit-appearance: none;
        appearance: none;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background: #3498db;
        cursor: pointer;
        margin-top: -8px;
    }
    .slider-value {
        width: 44px;
        margin-top: 6px;
        font-size: 0.8rem;
    }
}

/* ===== PULSANTI PROGRAMMA - FUNZIONANTI! ===== */
.programma-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    justify-content: center;
}
.programma-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #d5dbdb;
    background: white;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #2c3e50;
}
.programma-btn:hover {
    border-color: #3498db;
    transform: scale(1.05);
}
.programma-btn.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}
.programma-btn[data-value="P"].active {
    background: #e67e22;
    border-color: #e67e22;
    box-shadow: 0 0 8px rgba(230, 126, 34, 0.4);
}

/* ===== GIORNI DELLA SETTIMANA ===== */
.giorni-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    justify-content: center;
}
.giorno-btn {
    padding: 3px 8px;
    border-radius: 8px;
    border: 2px solid #e8ecf0;
    background: white;
    cursor: pointer;
    font-size: 0.6rem;
    font-weight: 600;
    transition: all 0.2s;
    color: #7f8c8d;
    min-width: 30px;
    text-align: center;
}
.giorno-btn:hover {
    border-color: #3498db;
    background: #f0f8ff;
    transform: translateY(-1px);
}
.giorno-btn.active {
    background: #2ecc71;
    color: white;
    border-color: #2ecc71;
    box-shadow: 0 2px 8px rgba(46, 204, 113, 0.3);
}

/* ===== FORM ACTIONS ===== */
.form-actions {
    margin-top: 12px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.btn-primary, .btn-secondary {
    padding: 8px 22px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}
.btn-primary {
    background: #3498db;
    color: white;
}
.btn-primary:hover { background: #2980b9; }
.btn-secondary {
    background: #ecf0f1;
    color: #555;
}
.btn-secondary:hover { background: #d5dbdb; }

/* ===== POPUP ===== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.popup-content {
    background: white;
    border-radius: 12px;
    padding: 40px 50px;
    max-width: 450px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.popup-content.success {
    border-top: 5px solid #2ecc71;
}
.popup-content .popup-icon {
    font-size: 60px;
    color: #2ecc71;
    margin-bottom: 15px;
}
.popup-content h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: #2c3e50;
}
.popup-content p {
    color: #666;
    margin-bottom: 20px;
}
.popup-content .btn-primary {
    padding: 10px 40px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    background: #3498db;
    color: white;
}
.popup-content .btn-primary:hover { background: #2980b9; }

@media (max-width: 600px) {
    body { padding: 6px; }
    .form-card { padding: 10px 12px; }
    .form-row { flex-direction: column; gap: 8px; }
    .form-group { flex: 1 1 100%; }
    .sliders-container { flex-wrap: wrap; gap: 8px; }
    .slider-item { flex: 1 1 45%; min-width: 60px; }
    .dropdown-bar { flex-direction: column; align-items: stretch; }
    .dropdown-bar select { width: 100%; }
    .dropdown-bar .btn-secondary { width: 100%; justify-content: center; }
    header h1 { font-size: 1.2rem; }
    .user-info { font-size: 0.75rem; gap: 6px; }
    .btn-help { font-size: 0.7rem; padding: 4px 10px; }
    .btn-logout { font-size: 0.7rem; padding: 4px 10px; }
    body { overflow: auto; }
    .popup-content { padding: 30px 20px; }
    .popup-content .popup-icon { font-size: 40px; }
    .giorno-btn { font-size: 0.5rem; padding: 2px 5px; min-width: 24px; }
}