/* --- VARIABLES DE COLOR --- */
:root {
    --bg-dark: #121212;
    --card-bg: #1e1e1e;
    --text-main: #ffffff;
    --text-dim: #b3b3b3;
    --accent-tenis: #2ecc71;  /* Verde Tenis */
    --accent-padel: #3498db;  /* Azul Pádel */
    --status-on: #1b4d31;     /* Fondo verde oscuro para ON */
    --status-off: #2c3e50;    /* Fondo azul grisáceo para OFF */
    --manual-border: #f1c40f; /* Borde amarillo para indicar Manual */
    --danger: #e74c3c;
    --warning: #f39c12;
}

/* --- ESTILOS GENERALES --- */
body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.container {
    width: 100%;
    max-width: 800px;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    margin: 5px 0;
    font-size: 1.8em;
}

.logout {
    color: var(--danger);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9em;
}

/* --- MENSAJES DE ESTADO --- */
.status-msg {
    background: rgba(46, 204, 113, 0.2);
    border: 1px solid var(--accent-tenis);
    color: var(--accent-tenis);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

/* --- BOTONES PRINCIPALES --- */
.btn-sync {
    width: 100%;
    padding: 15px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.1s;
}

.btn-sync:active {
    transform: scale(0.98);
}

/* --- GRID DE PISTAS --- */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.pista-card {
    background: var(--card-bg);
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

/* Colores según estado Shelly */
.pista-on {
    background: var(--status-on) !important;
    border-bottom: 5px solid var(--accent-tenis);
}

.pista-off {
    background: var(--card-bg);
}

/* Borde amarillo si el archivo .lock existe (Modo Manual) */
.manual-active {
    border: 2px solid var(--manual-border) !important;
}

.pista-card strong {
    font-size: 1.1em;
    display: block;
    margin-bottom: 5px;
}

.pista-card small {
    color: var(--text-dim);
    display: block;
    margin-bottom: 10px;
}

/* --- SELECTOR DE TIEMPO --- */
.select-tiempo {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    background: #2a2a2a;
    color: white;
    border: 1px solid #444;
    border-radius: 6px;
    font-size: 0.9em;
    outline: none;
}

/* --- BOTONES DE PISTA --- */
.btn-pista {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    font-size: 0.85em;
}

.btn-pista.on { background: var(--accent-tenis); color: white; }
.btn-pista.auto { background: var(--warning); color: white; }
.btn-pista.info { background: #444; color: #888; cursor: not-allowed; }

/* --- SECCIONES --- */
h2 {
    font-size: 1.2em;
    margin-top: 20px;
    padding-bottom: 5px;
    border-bottom: 1px solid #333;
}

.badge-tenis { color: var(--accent-tenis); }
.badge-padel { color: var(--accent-padel); }

/* --- ESTILOS LOGIN --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    margin: 0;
    background-color: var(--bg-dark);
}

.login-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    width: 320px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.login-card input {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border-radius: 8px;
    border: 1px solid #333;
    background: #252525;
    color: white;
    box-sizing: border-box;
}

.login-card button {
    width: 100%;
    padding: 12px;
    background: var(--accent-padel);
    border: none;
    color: white;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    margin-top: 10px;
}
/* --- SISTEMA DE CARGA (SPINNER) --- */
.loader-container {
    display: none; /* Se activa por JS */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.loader-spinner {
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-left-color: #4facfe; /* El azul de tu web */
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
}

.loader-text {
    color: #4facfe;
    font-size: 11px;
    margin-top: 8px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Estado bloqueado para botones */
button:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
    filter: grayscale(0.5);
}

/* --- RESPONSIVE --- */
@media (max-width: 480px) {
    .grid {
        grid-template-columns: 1fr 1fr;
    }
}
