:root {
    --bg-color: #f8fafc;
    --panel-bg: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --accent: #1e3a8a;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* ---------------------------------
   VISTA DE ADMINISTRADOR (INDEX)
------------------------------------ */
.container {
    display: flex;
    gap: 2rem;
    width: 100%;
    max-width: 1500px;
}
.admin-container {
    height: 90vh;
}

.settings-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    width: 420px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}

.settings-scroll {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 1rem;
}

/* Custom Scrollbar */
.settings-scroll::-webkit-scrollbar { width: 6px; }
.settings-scroll::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 4px; }
.settings-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

header p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"], input[type="number"], textarea, select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.2s;
    background: #f8fafc;
    cursor: text;
}

select { cursor: pointer; }

input[type="text"]:focus, input[type="number"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
    background: #ffffff;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #f8fafc;
}

input[type="color"] {
    appearance: none;
    -webkit-appearance: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }

#colorHex {
    font-family: monospace;
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 600;
}

button {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 1.1rem;
    background-color: var(--accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

button:hover:not(:disabled) { filter: brightness(0.9); }
button:disabled { background-color: #cbd5e1; color: #64748b; cursor: not-allowed; }

/* Vista Previa */
.preview-panel {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #e2e8f0;
    border-radius: 16px;
    padding: 2rem;
    overflow: hidden;
}

.canvas-wrapper {
    background: white;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    max-height: 100%;
    max-width: 100%;
    display: flex;
    aspect-ratio: 1.414;
}

canvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Modal del QR */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.hidden { display: none !important; }

.modal-content {
    background: white;
    padding: 3rem;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes scaleIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.close-btn {
    position: absolute;
    top: 15px; right: 15px;
    background: none; border: none;
    font-size: 2rem; color: var(--text-secondary);
    cursor: pointer; width: auto; padding: 0; margin: 0;
    line-height: 1;
    transition: color 0.2s;
}
.close-btn:hover { color: var(--text-primary); filter: none; background: transparent; }

.qr-wrapper h2 { font-size: 1.8rem; color: var(--text-primary); margin-bottom: 0.5rem; }
.qr-settings {
    display: flex; align-items: center; gap: 0.8rem;
    background: #f1f5f9; padding: 0.8rem 1.5rem; border-radius: 8px;
    margin-bottom: 1rem;
}
.qr-settings label { font-size: 0.9rem; margin: 0; }
.qr-settings input { width: 70px; padding: 0.5rem; text-align: center; }
.qr-settings .tooltip { font-size: 0.8rem; color: var(--text-secondary); font-weight: normal; text-transform: none; }

.qr-box img {
    width: 350px; height: 350px;
    border-radius: 12px;
    border: 4px solid var(--accent);
    padding: 10px;
}
.download-qr-btn {
    background-color: #f1f5f9; color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.8rem 1.5rem; margin-top: 1rem;
    width: auto;
}
.download-qr-btn:hover { background-color: #e2e8f0; }

.qr-wrapper .instruction { color: var(--text-secondary); font-size: 1.1rem; }
.direct-link {
    color: var(--accent); font-weight: 600;
    text-decoration: none; margin-top: 0.5rem;
    padding: 0.5rem 1rem; border-radius: 8px;
}
.direct-link:hover { background: #f1f5f9; }

/* ---------------------------------
   VISTA DE PARTICIPANTE (MÓVIL)
------------------------------------ */
.mobile-view { background-color: white; align-items: flex-start; padding: 0; }
.download-container {
    width: 100%; max-width: 500px; margin: 0 auto;
    padding: 2rem 1.5rem; display: flex; flex-direction: column;
    align-items: center; min-height: 100vh;
}
.logo-header { margin-bottom: 2rem; }
.mobile-logo { max-height: 95px; width: auto; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.08)); }
.course-info { text-align: center; margin-bottom: 2.5rem; width: 100%; }
.course-info h1 { font-size: 1.25rem; color: var(--accent); margin-bottom: 0.5rem; letter-spacing: 0.5px; }
.course-info p { font-size: 1.05rem; color: var(--text-primary); font-weight: 700; }
.mobile-form { width: 100%; display: flex; flex-direction: column; gap: 1.2rem; }
.mobile-form label { font-size: 0.95rem; text-align: center; color: var(--text-secondary); line-height: 1.4; }
.mobile-form input {
    text-align: center; font-size: 1rem; padding: 1rem;
    border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.mobile-form button {
    padding: 1rem; font-size: 1.05rem; border-radius: 12px;
    margin-top: 0.5rem; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.error-msg {
    text-align: center; color: #ef4444; background: #fef2f2;
    padding: 1.5rem; border-radius: 12px; width: 100%; font-weight: 600; border: 1px solid #fca5a5;
}

/* ---------------------------------
   MEDIA QUERIES (RESPONSIVE ADMIN)
------------------------------------ */
@media (max-width: 900px) {
    body {
        padding: 1rem;
    }
    .container {
        flex-direction: column;
    }
    .admin-container {
        height: auto;
    }
    .settings-panel {
        width: 100%;
        padding: 1.5rem;
    }
    .preview-panel {
        padding: 1rem;
        order: -1; /* Para que la vista previa salga arriba del formulario en móviles */
    }
    .modal-content {
        padding: 2rem 1.5rem;
        width: 95%;
    }
    .qr-box img {
        width: 100%;
        height: auto;
        max-width: 300px;
    }
    .qr-settings {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .qr-settings input {
        width: 100%;
    }
}
