/* =================================================================
   SISTEMA DE ASAMBLEA - HOJA DE ESTILOS DEFINITIVA V8.0 (FINAL)
   ================================================================= */

/* --- IMPORTACIÓN DE FUENTE (DEBE SER LA PRIMERA REGLA) --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');

/* --- VARIABLES Y CONFIGURACIÓN GENERAL --- */
:root {
    --primary-color: #4A90E2;
    --primary-dark: #357ABD;
    --secondary-color: #50E3C2;
    --danger-color: #D0021B;
    --light-gray: #f4f7f6;
    --medium-gray: #e8e8e8;
    --dark-gray: #4a4a4a;
    --text-color: #333;
    --border-radius: 8px;
    --box-shadow: 0 5px 15px rgba(0,0,0,0.08);
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--light-gray);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; animation: fadeIn 0.5s ease-in-out; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    background-color: #fff;
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 25px;
    box-shadow: var(--box-shadow);
    border: 1px solid var(--medium-gray);
}

/* --- PANTALLA DE LOGIN --- */
#login-view .card {
    max-width: 420px;
    margin: 50px auto;
    text-align: center;
}
#login-view h1 {
    font-size: 1.8em;
    color: var(--primary-color);
    margin-bottom: 10px;
}
#login-view p {
    color: #777;
    margin-bottom: 30px;
}
.admin-link {
    margin-top: 25px;
    font-size: 0.9em;
}
.admin-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}
.admin-link a:hover {
    text-decoration: underline;
}

/* --- CABECERA DEL DASHBOARD --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px 30px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    box-shadow: var(--box-shadow);
}
.welcome-message h2 { margin: 0; font-weight: 500; }
.coeficiente-display {
    margin: 5px 0 0 0;
    font-size: 0.9em;
    opacity: 0.8;
}
.quorum-display { text-align: center; }
.quorum-display h3 { margin: 0 0 5px 0; font-size: 1em; opacity: 0.9; font-weight: 400; }
.quorum-value { font-size: 2.5em; font-weight: 700; line-height: 1; }
.quorum-attendees { font-size: 0.9em; opacity: 0.8; }

/* --- FORMULARIOS Y BOTONES --- */
.form-group { margin-bottom: 20px; text-align: left; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 0.9em; }
input[type="text"], input[type="password"], input[type="file"], input[type="number"], textarea, select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-family: var(--font-family);
    font-size: 1em;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: #fff;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
    outline: none;
}
textarea { resize: vertical; }

button {
    display: inline-block;
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: 5px;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-align: center;
}
button:hover { background-color: var(--primary-dark); }
button:active { transform: scale(0.98); }
button:disabled { background-color: #ccc; cursor: not-allowed; }

.btn-secondary { background-color: #6c757d; }
.btn-secondary:hover { background-color: #5a6268; }
.btn-success { background-color: var(--secondary-color); color: var(--dark-gray); }
.btn-success:hover { background-color: #48d1b1; }
.btn-danger { background-color: var(--danger-color); }
.btn-danger:hover { background-color: #b80218; }

/* --- MENSAJES DE ESTADO --- */
.error-message { color: var(--danger-color); margin-top: 15px; font-weight: 500; }
.success-message { color: #28a745; margin-top: 15px; font-weight: 500; }
.status-message { margin-top: 15px; font-style: italic; color: #555; }

/* --- SECCIONES DE VOTACIÓN --- */
.question {
    border: 1px solid var(--medium-gray);
    padding: 25px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
    transition: all 0.3s ease;
}
.question h3 { margin-top: 0; font-size: 1.4em; }
.question.open { border-left: 5px solid var(--secondary-color); }
.question.closed { border-left: 5px solid var(--danger-color); }
.question.pending { border-left: 5px solid #ccc; }

.options-list {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}
.options-list button { width: 100%; font-weight: 500; }
.voted-message { padding: 15px; border-radius: 5px; text-align: center; font-weight: 500; }

/* --- GRÁFICOS Y REPORTES --- */
.charts-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 20px;
    align-items: center;
}
.chart-container {
    position: relative;
    height: 280px;
    flex: 1;
    min-width: 250px;
}
.question-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background-color: var(--light-gray);
    padding: 10px 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}
.timer {
    font-size: 1.2em;
    color: var(--primary-color);
    font-weight: 700;
}
.chart-summary {
    margin-top: 25px;
}
.summary-table table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.summary-table th, .summary-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
}
.summary-table thead th {
    background-color: #f2f2f2; font-weight: 700;
}
.summary-table tbody td:nth-child(2), .summary-table tbody td:nth-child(3), .summary-table tbody td:nth-child(4) {
    text-align: center;
}
.summary-table tfoot {
    background-color: #f8f8f8;
    font-weight: bold;
}
.summary-table tfoot td:nth-child(2) {
    text-align: center;
}


/* --- PANEL DE ADMINISTRADOR --- */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 30px;
}
.admin-section {
    border-top: 1px solid var(--medium-gray);
    padding-top: 25px;
    margin-top: 25px;
}
.admin-section:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}
.admin-section h3 { font-size: 1.2em; color: var(--primary-color); margin-top: 0; }
.option-input { display: flex; align-items: center; gap: 10px; }
.option-input label { flex-shrink: 0; }
.option-input input { flex-grow: 1; }
#add-option-btn { margin: 15px 0; width: auto; font-weight: 500; padding: 8px 15px; font-size: 0.9em; }

.question-admin-controls {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.question-admin-controls button { width: auto; font-size: 0.9em; padding: 8px 15px; }
.btn-download {
    background-color: #17a2b8;
}
.btn-download:hover {
    background-color: #138496;
}

.general-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.general-controls button {
    width: auto;
    flex-grow: 1;
}

/* --- MODAL DE VOTANTES --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    animation: fadeIn 0.3s;
}
.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 30px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: var(--border-radius);
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.close-btn {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.voters-lists {
    display: grid;
    grid-template-columns: 1fr;
    margin-top: 20px;
}
.voter-list-container {
    border: 1px solid #eee;
    padding: 15px;
    border-radius: 5px;
    max-height: 40vh;
    overflow-y: auto;
}
.voter-list-container h4 { margin-top: 0; }
.voter-list-container ul {
    list-style-type: none;
    padding: 0;
}
.voter-list-container li {
    padding: 8px;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 500;
}
li.voted { color: #28a745; }

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
    .admin-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .dashboard-header { flex-direction: column; text-align: center; }
    .card { padding: 20px; }
    .general-controls { flex-direction: column; }
}

/* =================================================================
   ESTILOS ADICIONALES PARA NUEVAS FUNCIONALIDADES (AÑADIDOS)
   ================================================================= */

.hidden-section {
    display: none;
}

.highlight {
    color: var(--primary-color);
    font-weight: 700;
}

.form-group {
    position: relative;
}

.search-results-list {
    border: 1px solid #ccc;
    border-radius: 5px;
    max-height: 150px;
    overflow-y: auto;
    background-color: #fff;
    position: absolute;
    width: 100%;
    z-index: 10;
    box-shadow: 0 5px 10px rgba(0,0,0,0.1);
    display: none; /* Oculto por defecto */
}

.search-result-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}
.search-result-item:hover {
    background-color: var(--light-gray);
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-item-none {
    padding: 10px;
    color: #888;
}

.active-proxies-ul {
    list-style: none;
    padding: 0;
    margin-top: 15px;
}
.active-proxies-ul li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--medium-gray);
}
.active-proxies-ul li:nth-child(even) {
    background-color: var(--light-gray);
}
.btn-small {
    padding: 5px 10px !important;
    font-size: 0.8em !important;
    width: auto !important;
    font-weight: 500 !important;
}

.voted-message.error-state {
    background-color: #ffedeb;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}
.voted-message.success-state {
    background-color: #e8f5e9;
    color: #28a745;
    border: 1px solid #28a745;
}

.proxy-details {
    margin-top: 10px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    font-size: 0.85em;
    border: 1px solid rgba(255,255,255,0.2);
}
.proxy-details p {
    margin: 0 0 5px 0;
    color: white;
    opacity: 0.9;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(255,255,255,0.3);
}
.proxy-detail-item {
    display: flex;
    justify-content: space-between;
    padding: 3px 5px;
}
.mora-si {
    color: #ffc2bd;
    font-weight: bold;
}
.mora-no {
    color: #c9f7f5;
    font-weight: bold;
}

.tabs-container {
    margin-top: 30px;
}
.tab-nav {
    display: flex;
    border-bottom: 1px solid var(--medium-gray);
    flex-wrap: wrap;
}
.tab-button {
    padding: 12px 20px;
    cursor: pointer;
    border: 1px solid transparent;
    border-bottom: none;
    background-color: transparent;
    font-size: 1em;
    font-weight: 500;
    color: var(--dark-gray);
    margin-bottom: -1px;
    border-radius: 5px 5px 0 0;
    width: auto;
    transition: all 0.2s ease-in-out;
}
.tab-button:hover {
    background-color: var(--light-gray);
}
.tab-button.active {
    color: var(--primary-color);
    border-color: var(--medium-gray);
    background-color: white;
}
.tab-pane {
    display: none;
    animation: fadeIn 0.5s;
    border: 1px solid var(--medium-gray);
    padding: 1px;
    border-top: none;
    border-radius: 0 0 5px 5px;
    background-color: white;
}
.tab-pane.active {
    display: block;
}
.tab-pane .card {
    box-shadow: none;
    border: none;
    margin-bottom: 0;
}

.settings-container { display: flex; flex-direction: column; gap: 20px; max-width: 600px; }
.setting-item { display: flex; justify-content: space-between; align-items: center; background: #f9f9f9; padding: 15px; border-radius: 5px; }
.setting-item label { font-weight: 500; margin: 0; }
.switch { position: relative; display: inline-block; width: 60px; height: 34px; flex-shrink: 0; margin-left: 15px;}
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(26px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

.user-table { width: 100%; border-collapse: collapse; margin-top: 15px; }
.user-table th, .user-table td { border: 1px solid #ddd; padding: 10px; text-align: left; }
.user-table thead th { background-color: #f2f2f2; }
.user-table td button { width: 100%; }

.danger-zone { display: flex; flex-direction: column; gap: 15px; max-width: 400px; }