:root {
    --guindo: #AF272F;
    --guindo-hover: #8B1A24;
    --guindo-dark: #6B121C;
    --beige: #E8D5B7;
    --beige-light: #F5F0E8;
    --beige-border: #D4C5A9;
    --white: #FFFFFF;
    --text: #2D2D2D;
    --text-light: #6B6B6B;
    --shadow: rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-sm: 4px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--beige-light);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--guindo);
    text-decoration: none;
}

a:hover {
    color: var(--guindo-hover);
}

/* ========== LAYOUT ========== */

.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 20px 16px;
    min-height: 100vh;
}

.container-wide {
    max-width: 960px;
}

/* ========== HEADER ========== */

.header {
    background: var(--guindo);
    color: var(--white);
    padding: 16px 20px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px var(--shadow);
}

.header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.3;
}

.header .subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 4px;
}

/* ========== CARDS ========== */

.card {
    background: var(--white);
    border: 1px solid var(--beige-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px var(--shadow);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--guindo);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--beige);
}

/* ========== FORMS ========== */

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.9rem;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--beige-border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: var(--white);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--guindo);
    box-shadow: 0 0 0 3px rgba(175,39,47,0.15);
}

/* ========== BUTTONS ========== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.97);
}

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

.btn-primary:hover {
    background: var(--guindo-hover);
}

.btn-secondary {
    background: var(--beige);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--beige-border);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 14px 24px;
    font-size: 1.1rem;
    border-radius: var(--radius);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-danger {
    background: #dc3545;
    color: var(--white);
}

.btn-danger:hover {
    background: #c82333;
}

/* ========== LOGIN ========== */

.login-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--guindo) 0%, var(--guindo-hover) 100%);
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-card h2 {
    text-align: center;
    color: var(--guindo);
    margin-bottom: 8px;
    font-size: 1.3rem;
}

.login-card .login-subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

.login-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.9rem;
    text-align: center;
    display: none;
}

/* ========== SURVEY ========== */

.survey-header {
    text-align: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, var(--guindo) 0%, var(--guindo-hover) 100%);
    color: var(--white);
}

.survey-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.survey-header p {
    font-size: 0.85rem;
    opacity: 0.9;
}

.survey-start {
    text-align: center;
    padding: 40px 16px;
}

.survey-start p {
    margin-bottom: 24px;
    color: var(--text-light);
}

/* ========== QUESTION ========== */

.question-block {
    background: var(--white);
    border: 1px solid var(--beige-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 12px;
}

.question-text {
    font-weight: 500;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.question-required::after {
    content: ' *';
    color: #dc2626;
}

/* Radio / Checkbox options */
.options-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--beige-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    font-size: 0.95rem;
}

.option-label:hover {
    background: var(--beige-light);
}

.option-label input[type="radio"],
.option-label input[type="checkbox"] {
    accent-color: var(--guindo);
    width: 18px;
    height: 18px;
}

.option-label.selected {
    border-color: var(--guindo);
    background: rgba(175,39,47,0.08);
}

/* Scale buttons 1-5 */
.scale-group {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.scale-btn {
    flex: 1;
    aspect-ratio: 1;
    max-width: 56px;
    border: 2px solid var(--beige-border);
    border-radius: 50%;
    background: var(--white);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text);
}

.scale-btn:hover {
    border-color: var(--guindo);
    color: var(--guindo);
}

.scale-btn.active {
    border-color: var(--guindo);
    background: var(--guindo);
    color: var(--white);
}

.scale-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 4px;
    padding: 0 2px;
}

/* Autocomplete */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-wrapper input {
    width: 100%;
}

.autocomplete-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: var(--white);
    border: 1px solid var(--beige-border);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    z-index: 50;
    display: none;
}

.autocomplete-list.show {
    display: block;
}

.autocomplete-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9rem;
}

.autocomplete-item:hover {
    background: var(--beige-light);
}

/* ========== NAVIGATION ========== */

.survey-nav {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding: 20px 0;
}

.survey-nav .btn {
    flex: 1;
}

/* ========== PROGRESS ========== */

.progress-bar {
    height: 6px;
    background: var(--beige-border);
    border-radius: 3px;
    margin-bottom: 20px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--guindo);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 16px;
}

/* ========== ADMIN LAYOUT ========== */

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 220px;
    background: var(--guindo);
    color: var(--white);
    padding: 20px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.admin-sidebar .brand {
    text-align: center;
    padding: 16px;
    font-weight: 600;
    font-size: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    margin-bottom: 8px;
}

.admin-sidebar .brand span {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.8;
    margin-top: 4px;
}

.admin-sidebar a {
    display: block;
    padding: 10px 20px;
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
    transition: background 0.2s;
}

.admin-sidebar a:hover,
.admin-sidebar a.active {
    background: rgba(255,255,255,0.15);
    color: var(--white);
}

.admin-main {
    margin-left: 220px;
    flex: 1;
    padding: 24px;
    min-height: 100vh;
}

.admin-main h2 {
    color: var(--guindo);
    margin-bottom: 20px;
}

/* ========== TABLES ========== */

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border: 1px solid var(--beige-border);
    border-radius: var(--radius);
    overflow: hidden;
}

table th {
    background: var(--guindo);
    color: var(--white);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
}

table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--beige-light);
    font-size: 0.9rem;
}

table tr:hover {
    background: var(--beige-light);
}

/* ========== STATS CARDS ========== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--beige-border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--guindo);
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ========== MODAL ========== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    color: var(--guindo);
    margin-bottom: 16px;
}

.modal-grafica {
    max-width: 700px !important;
}

/* ========== TOAST ========== */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s;
    z-index: 300;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    background: #16a34a;
}

.toast.error {
    background: #dc2626;
}

/* ========== RESPONSIVE ========== */

@media (max-width: 768px) {
    .admin-sidebar {
        width: 100%;
        position: relative;
        height: auto;
        padding: 0;
        display: flex;
        flex-wrap: wrap;
    }

    .admin-sidebar .brand {
        width: 100%;
        padding: 12px 16px;
        margin-bottom: 0;
    }

    .admin-sidebar a {
        flex: 1;
        text-align: center;
        padding: 10px 8px;
        font-size: 0.8rem;
        min-width: 80px;
    }

    .admin-main {
        margin-left: 0;
        padding: 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .scale-group {
        gap: 6px;
    }

    .scale-btn {
        max-width: 48px;
        font-size: 0.9rem;
    }
}

@media (max-width: 380px) {
    .container {
        padding: 12px 10px;
    }

    .scale-btn {
        max-width: 40px;
        font-size: 0.8rem;
    }
}

/* ========== UTILITIES ========== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* ========== IMAGE GRID ========== */

.image-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-height: 520px;
    overflow-y: auto;
    padding: 4px 0;
}

.image-option {
    border: 2px solid var(--beige-border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
    background: var(--white);
    height: 180px;
    position: relative;
    display: block;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.image-option:focus,
.image-option:focus-within,
.image-option:focus-visible {
    outline: none;
}

.image-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.image-option:hover {
    border-color: var(--guindo);
}

.image-option:active {
    transform: scale(0.95);
}

.image-option.selected {
    border-color: var(--guindo);
    box-shadow: 0 0 0 3px rgba(175,39,47,0.3);
}

.image-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.image-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: var(--guindo);
    color: var(--white);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* ========== OPTIONS WITH LOGOS ========== */

.options-with-logos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.option-logo {
    flex-direction: column;
    text-align: center;
    gap: 6px;
    padding: 12px 8px;
}

.option-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

@media (max-width: 380px) {
    .options-with-logos {
        grid-template-columns: 1fr;
    }
}

/* ========== END SCREEN ========== */

.end-screen {
    text-align: center;
    padding: 40px 16px;
}

.end-screen h2 {
    color: var(--guindo);
    margin-bottom: 12px;
}

    .end-screen p {
        color: var(--text-light);
        margin-bottom: 24px;
    }

    /* ========== TEMA CARDS ========== */

    .tema-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
        gap: 16px;
        margin-top: 16px;
    }

    .tema-card {
        background: var(--white);
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 1px 4px rgba(0,0,0,0.08);
        border: 1px solid #e2e8f0;
    }

    .tema-card-header {
        padding: 16px 16px 8px;
    }

    .tema-card-title {
        font-weight: 700;
        font-size: 1rem;
        color: var(--guindo);
    }

    .tema-card-meta {
        font-size: 0.8rem;
        color: var(--text-light);
        margin-top: 4px;
    }

    .tema-card-body {
        padding: 4px 16px 8px;
    }

    .tema-pregunta-row {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 4px 0;
        font-size: 0.85rem;
    }

    .tema-pregunta-texto {
        flex: 0 0 140px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        color: var(--text);
    }

    .tema-bar-bg {
        flex: 1;
        height: 8px;
        background: #e2e8f0;
        border-radius: 4px;
        overflow: hidden;
    }

    .tema-bar-fill {
        height: 100%;
        background: var(--guindo);
        border-radius: 4px;
        transition: width 0.4s ease;
    }

    .tema-pregunta-valor {
        flex: 0 0 32px;
        text-align: right;
        font-weight: 600;
        font-size: 0.8rem;
        color: var(--guindo);
    }

    @media (max-width: 480px) {
        .tema-grid {
            grid-template-columns: 1fr;
        }
        .tema-pregunta-texto {
            flex: 0 0 100px;
        }
    }

    .scale-btn-custom {
        flex: 1;
        padding: 10px 16px;
        border: 2px solid var(--beige-border);
        border-radius: 24px;
        background: var(--white);
        font-size: 0.95rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        color: var(--text);
        white-space: nowrap;
    }
    .scale-btn-custom:hover {
        border-color: var(--guindo);
        color: var(--guindo);
    }
    .scale-btn-custom.active {
        border-color: var(--guindo);
        background: var(--guindo);
        color: var(--white);
    }

    .no-image-option {
        display: flex !important;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 8px;
        font-size: 0.75rem;
        background: #f5f5f5;
        border: 2px dashed #ccc;
        color: #666;
        font-weight: 600;
        height: 180px;
        position: relative;
    }
    .no-image-option.selected {
        border-color: var(--guindo);
        box-shadow: 0 0 0 3px rgba(175,39,47,0.3);
        background: #fce8e8;
        color: var(--guindo);
    }

/* ========== LANDING CANDIDATE SPHERE ========== */

.sphere-container {
    perspective: 1000px;
    width: 260px;
    height: 260px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sphere-ring {
    width: 200px;
    height: 200px;
    position: relative;
    transform-style: preserve-3d;
    animation: girarEsfera 45s infinite linear;
}

.sphere-ring:hover {
    animation-play-state: paused;
}

@keyframes girarEsfera {
    from { transform: rotateY(0deg) rotateX(12deg); }
    to { transform: rotateY(360deg) rotateX(12deg); }
}

.sphere-item {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.8);
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    backface-visibility: hidden;
    left: 50%;
    top: 50%;
    margin-left: -22px;
    margin-top: -22px;
}

.sphere-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

@media (min-width: 480px) {
    .sphere-container {
        width: 300px;
        height: 300px;
    }
    .sphere-ring {
        width: 240px;
        height: 240px;
    }
    .sphere-item {
        width: 38px;
        height: 38px;
        margin-left: -19px;
        margin-top: -19px;
    }
}

@media (min-width: 480px) {
    .sphere-container {
        width: 340px;
        height: 340px;
    }
    .sphere-ring {
        width: 280px;
        height: 280px;
    }
    .sphere-item {
        width: 42px;
        height: 42px;
        margin-left: -21px;
        margin-top: -21px;
    }
}
}
