/* ==========================================================================
   1. SISTEMA DE VARIABLES (DISEÑO TOKENS)
   ========================================================================== */
:root {
    /* Fondo y Texto General */
    --bg-color: #f4f4f4;          /* Fondo general del sitio */
    --card-bg: #ffffff;           /* Fondo de tarjetas/contenedores */
    --text-color: #333333;        /* Texto principal */
    --text-secondary: #666666;    /* Texto secundario */
    
    /* Colores Primarios (Botones, enlaces, acentos) */
    --primary-color: #4CAF50;
    --primary-hover: #45a049;
    
    /* Bordes */
    --border-color: #dddddd;
    
    /* Formularios (Inputs, Selects, Textareas) */
    --input-bg: #ffffff;
    --input-text: #333333;
    --input-border: #cccccc;
    --input-focus: #4CAF50;
    
    /* Navegación (Panel Admin) */
    --nav-bg: #ffffff;
    --nav-border: #e0e0e0;
    --nav-link-hover: #f4f4f4;
    
    /* Tablas (Panel Admin) */
    --table-header-bg: #4CAF50;
    --table-header-text: #ffffff;
    --table-row-alt: #f9f9f9;
    
    /* Alertas */
    --alert-success-bg: #d4edda;
    --alert-success-text: #155724;
    --alert-error-bg: #f8d7da;
    --alert-error-text: #721c24;
}

/* Modo Oscuro */
body.dark-mode {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --text-secondary: #a0a0a0;
    
    --primary-color: #81C784;
    --primary-hover: #66BB6A;
    
    --border-color: #333333;
    
    --input-bg: #2c2c2c;
    --input-text: #e0e0e0;
    --input-border: #444444;
    --input-focus: #81C784;
    
    --nav-bg: #1e1e1e;
    --nav-border: #333333;
    --nav-link-hover: #333333;
    
    --table-header-bg: #2E7D32;
    --table-header-text: #ffffff;
    --table-row-alt: #252525;
    
    --alert-success-bg: #1b3a1b;
    --alert-success-text: #81C784;
    --alert-error-bg: #3a1b1b;
    --alert-error-text: #f8d7da;
}

/* ==========================================================================
   2. RESET Y ELEMENTOS BASE
   ========================================================================== */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4 {
    color: var(--text-color);
    margin-top: 0;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover { color: var(--primary-hover); }

img { max-width: 100%; height: auto; }

/* ==========================================================================
   3. LAYOUT (Contenedores)
   ========================================================================== */
.container {
    max-width: 100%;
    padding: 20px;
    margin: 0 auto;
}
@media (min-width: 600px) {
    .container { max-width: 800px; }
}
@media (min-width: 992px) {
    .container-admin { max-width: 1200px; } /* Clase para el panel admin */
}

.card {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* ==========================================================================
   4. HEADER Y FOOTER
   ========================================================================== */
header {
    background-color: var(--card-bg);
    color: var(--primary-color);
    text-align: center;
    padding: 1.5em 0;
    border-bottom: 2px solid var(--primary-color);
    position: relative;
    transition: all 0.3s ease;
}

footer {
    background-color: var(--primary-color);
    color: #FFFFFF;
    text-align: center;
    padding: 1em 0;
    margin-top: 30px;
}

/* ==========================================================================
   5. FORMULARIOS (Solución al problema de Dark Mode)
   ========================================================================== */
/* Aplica a TODOS los inputs de texto, email, password y selects */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    box-sizing: border-box;
    background-color: var(--input-bg); /* Antes estaba en #fff fijo */
    color: var(--input-text);          /* Antes estaba en #333 fijo */
    font-size: 16px;
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--input-focus);
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.form-group { margin-bottom: 15px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--text-color);
}
.error-msg { color: #f44336; font-size: 12px; margin-top: 5px; display: none; }

/* Switch Toggle (Botón deslizable) */
.switch { position: relative; display: inline-block; width: 30px; height: 16px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: #ccc; transition: .4s; border-radius: 16px; }
.slider:before { content: ""; position: absolute; height: 12px; width: 12px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(14px); }

/* Tooltip de ayuda */
.info-icon { cursor: pointer; color: var(--primary-color); font-size: 18px; margin-left: 5px; position: relative; display: inline-block; }
.tooltip-text { visibility: hidden; width: 350px; background-color: #333; color: #fff; text-align: left; border-radius: 5px; padding: 10px; position: absolute; z-index: 10; bottom: 125%; left: 50%; transform: translateX(-50%); opacity: 0; transition: opacity 0.3s; font-size: 12px; font-family: monospace; white-space: pre-line; }
.info-icon:hover .tooltip-text { visibility: visible; opacity: 1; }
.highlight { color: #ffeb3b; font-weight: bold; }

/* ==========================================================================
   6. BOTONES
   ========================================================================== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.3s, transform 0.1s;
    font-weight: bold;
}
.btn:active { transform: scale(0.98); }

.btn-primary { background-color: var(--primary-color); color: white; width: 100%; }
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-primary:disabled { background-color: #a5d6a7; cursor: not-allowed; }

.btn-sm { padding: 6px 12px; font-size: 14px; width: auto; }
.btn-danger { background-color: #f44336; color: white; }
.btn-danger:hover { background-color: #d32f2f; }
.btn-warning { background-color: #ff9800; color: white; }
.btn-warning:hover { background-color: #e68a00; }

/* ==========================================================================
   7. NAVEGACIÓN (Preparado para Panel de Admin)
   ========================================================================== */
.navbar {
    background-color: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color 0.3s, border-color 0.3s;
}
.navbar-brand { font-size: 1.2em; font-weight: bold; color: var(--primary-color); }
.navbar-links { display: flex; gap: 15px; list-style: none; margin: 0; padding: 0; }
.navbar-links a { color: var(--text-color); font-weight: normal; padding: 5px 10px; border-radius: 4px;}
.navbar-links a:hover { background-color: var(--nav-link-hover); color: var(--primary-color); }
.navbar-links a.active { color: var(--primary-color); font-weight: bold; }

/* ==========================================================================
   8. TABLAS DE DATOS (Preparado para Panel de Admin)
   ========================================================================== */
.table-container { overflow-x: auto; margin-top: 20px; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--card-bg);
    transition: background-color 0.3s;
}
.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}
.data-table th {
    background-color: var(--table-header-bg);
    color: var(--table-header-text);
    font-weight: bold;
}
.data-table tr:nth-child(even) { background-color: var(--table-row-alt); }
.data-table tr:hover { background-color: var(--nav-link-hover); }

/* ==========================================================================
   9. ALERTAS Y MENSAJES
   ========================================================================== */
.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    font-weight: bold;
}
.alert-success { background-color: var(--alert-success-bg); color: var(--alert-success-text); }
.alert-error { background-color: var(--alert-error-bg); color: var(--alert-error-text); }

/* ==========================================================================
   10. DARK MODE TOGGLE (Botón de la esquina)
   ========================================================================== */
.theme-toggle {
    position: absolute;
    top: 15px;
    right: 20px;
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}
.theme-toggle:hover { background-color: var(--primary-color); color: var(--card-bg); }
/* Panel Admin - Solo Lectura */
.field-readonly {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.field-readonly input {
    background-color: var(--bg-color);
    color: var(--text-color);
    cursor: default;
    flex-grow: 1;
}
.copy-btn {
    background: none;
    border: 1px solid var(--border-color);
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.copy-btn:hover { background-color: var(--nav-link-hover); color: var(--primary-color); }
.section-title { border-bottom: 2px solid var(--primary-color); padding-bottom: 5px; margin-top: 30px; margin-bottom: 15px; }
.img-thumbnail { width: 180px; height: 350px; object-fit: contain; border: 1px solid var(--border-color); border-radius: 4px; cursor: pointer; }