/* =============================================
   Sistema Elezioni ANAC - Stili
   ============================================= */

:root {
    --primary-color: #b30000;
    --primary-dark: #8b0000;
    --success-color: #04a100;
    --white: #ffffff;
    --black: #000000;
    --gray-light: #f5f5f5;
    --gray: #666666;
}

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

body {
    font-family: 'Trebuchet MS', 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    color: var(--white);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    /* Spazio extra in fondo per non far coprire i contenuti dalla
       barra di conferma fissa (.conferma-box) durante la votazione */
    padding-bottom: 160px;
}

/* Header */
.header {
    text-align: center;
    padding: 30px 20px;
    background: rgba(0,0,0,0.2);
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.header p {
    font-size: 1.2em;
    opacity: 0.9;
}

/* Card */
.card {
    background: var(--white);
    border-radius: 10px;
    padding: 30px;
    margin-bottom: 20px;
    color: var(--black);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.card-title {
    color: var(--primary-color);
    font-size: 1.5em;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--gray);
}

.form-control {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    border: 2px solid #ddd;
    border-radius: 5px;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 15px 30px;
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
    border: 2px solid var(--primary-color);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline {
    background: transparent;
    color: var(--white);
    border: 2px solid var(--white);
}

.btn-outline:hover {
    background: var(--white);
    color: var(--primary-color);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-block {
    display: block;
    width: 100%;
}

/* Login Box */
.login-box {
    max-width: 400px;
    margin: 50px auto;
}

.login-box .card {
    text-align: center;
}

/* Votazione */
.votazione-header {
    background: rgba(0,0,0,0.3);
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
    border-radius: 10px;
}

.votazione-header h2 {
    font-size: 1.8em;
    text-transform: uppercase;
}

.votazione-header .info {
    margin-top: 10px;
    font-size: 1.1em;
    opacity: 0.9;
}

/* Griglia Candidati */
.candidati-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.candidato-card {
    background: var(--white);
    color: var(--black);
    padding: 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    border: 3px solid transparent;
}

.candidato-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.candidato-card.selected {
    border-color: var(--success-color);
    background: #e8f5e9;
}

.candidato-card .nome {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.candidato-card .circoscrizione {
    font-size: 0.9em;
    color: var(--gray);
}

/* Selezione Voti */
.selezione-container {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.selezione-box {
    flex: 1;
    min-width: 300px;
}

.selezione-box h3 {
    background: var(--primary-color);
    color: var(--white);
    padding: 15px;
    border-radius: 8px 8px 0 0;
    margin: 0;
}

.selezione-lista {
    background: var(--white);
    color: var(--black);
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
    padding: 15px;
    border-radius: 0 0 8px 8px;
}

.voto-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-transform: uppercase;
    padding: 10px 15px;
    background: var(--gray-light);
    margin-bottom: 8px;
    border-radius: 5px;
}

#altro-socio-select,
#altro-socio-select option {
    text-transform: uppercase;
}

.voto-item .remove {
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1.2em;
}

/* Timer */
.timer-box {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0,0,0,0.8);
    padding: 20px 30px;
    border-radius: 10px;
    text-align: center;
    z-index: 1000;
}

.timer-box .label {
    font-size: 0.9em;
    opacity: 0.8;
    margin-bottom: 5px;
}

.timer-box .time {
    font-size: 2.5em;
    font-weight: bold;
    font-family: monospace;
}

/* Conferma Voto */
.conferma-box {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.9);
    padding: 20px;
    text-align: center;
}

/* Risultati */
.risultato-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--white);
    color: var(--black);
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 5px solid transparent;
}

.risultato-item.eletto {
    border-left-color: var(--success-color);
    background: #e8f5e9;
}

.risultato-item .posizione {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--gray);
    width: 50px;
}

.risultato-item .nome {
    flex: 1;
    font-size: 1.1em;
}

.risultato-item .voti {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--primary-color);
}

/* Spoglio Animazione */
.scheda-spoglio {
    background: var(--white);
    color: var(--black);
    padding: 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    display: none;
}

.scheda-spoglio.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

.scheda-spoglio .peso {
    font-size: 1.5em;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.scheda-spoglio .voti-lista {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

.scheda-spoglio .voto {
    background: var(--gray-light);
    padding: 10px 20px;
    border-radius: 5px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Alert */
.alert {
    padding: 15px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8em;
    }
    
    .selezione-container {
        flex-direction: column;
    }
    
    .candidati-grid {
        grid-template-columns: 1fr;
    }
    
    /* Su mobile la barra di conferma non è più fissa: scorre col contenuto
       così non copre la tendina "Altri Soci" */
    .conferma-box {
        position: static;
        margin-top: 20px;
        border-radius: 10px;
    }
    
    .conferma-box .btn {
        width: 100%;
    }
    
    /* Su mobile la barra non è fissa, quindi non serve lo spazio extra */
    .container {
        padding-bottom: 20px;
    }
    
    /* Il timer non è più flottante a destra: appare sotto il voto,
       a tutta larghezza */
    .timer-box {
        position: static;
        width: 100%;
        margin: 15px 0 0 0;
        bottom: auto;
        right: auto;
        padding: 15px 20px;
        border-radius: 0;
    }
    
    .timer-box .time {
        font-size: 1.8em;
    }
}

/* Admin Styles */
.admin-nav {
    background: #333;
    padding: 15px 20px;
}

.admin-nav a {
    color: var(--white);
    text-decoration: none;
    margin-right: 20px;
    padding: 10px 15px;
    border-radius: 5px;
    transition: background 0.3s;
}

.admin-nav a:hover,
.admin-nav a.active {
    background: var(--primary-color);
}

.admin-body {
    background: var(--gray-light);
    min-height: 100vh;
    color: var(--black);
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px;
}

/* Tabelle Admin */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 8px;
    overflow: visible;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    font-size: 13px;
}

.table th,
.table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
    white-space: nowrap;
}

.table th {
    background: var(--primary-color);
    color: var(--white);
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.table td:nth-child(2) { /* Denominazione */
    white-space: normal;
    max-width: 250px;
    min-width: 150px;
}

.table td:nth-child(3) { /* Telefono */
    white-space: nowrap;
    font-family: monospace;
    font-size: 12px;
}

.table td:nth-child(6), /* Può Votare */
.table td:nth-child(7), /* Stato */
.table td:nth-child(8) { /* Delega */
    text-align: center;
}

.table td:nth-child(9) code { /* Password */
    font-family: monospace;
    font-size: 11px;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
}

.table td:last-child { /* Azioni */
    white-space: nowrap;
    text-align: center;
    width: 1%;
    min-width: 100px;
}

.table td:last-child form,
.table td:last-child .btn-group {
    display: inline-flex;
    gap: 2px;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
}

.table td:last-child .btn {
    padding: 0;
    font-size: 10px;
    width: 22px;
    height: 22px;
    min-width: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    margin: 0;
    line-height: 1;
}

.table td:last-child .btn i {
    font-size: 10px;
}

/* Bottoni azioni colorati */
.btn-sms {
    background: #28a745 !important;
    color: white !important;
    border-color: #28a745 !important;
}

.btn-edit {
    background: #17a2b8 !important;
    color: white !important;
    border-color: #17a2b8 !important;
}

.btn-password {
    background: #ffc107 !important;
    color: #212529 !important;
    border-color: #ffc107 !important;
}

.btn-delete {
    background: #dc3545 !important;
    color: white !important;
    border-color: #dc3545 !important;
}

.btn-toggle {
    background: #6c757d !important;
    color: white !important;
    border-color: #6c757d !important;
}

/* Bottone disabilitato - visibile ma non cliccabile */
.btn-disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.table tr:hover {
    background: #f9f9f9;
}

/* Responsive per tabelle admin */
@media (max-width: 1200px) {
    .table {
        font-size: 12px;
    }
    .table th,
    .table td {
        padding: 8px 6px;
    }
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.85em;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

/* Stati Sistema */
.stato-box {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
}

.stato-ASS { background: #fff3cd; color: #856404; }
.stato-INP { background: #d4edda; color: #155724; }
.stato-CHI { background: #f8d7da; color: #721c24; }
.stato-SPO { background: #d1ecf1; color: #0c5460; }
.stato-CLA { background: #e2e3e5; color: #383d41; }
