:root {
    /* Theme 1: Predeterminado */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #ec4899;
    --bg-gradient-start: #f8fafc;
    --bg-gradient-end: #e2e8f0;
    --surface: rgba(255, 255, 255, 0.7);
    --surface-border: rgba(255, 255, 255, 0.5);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --danger: #ef4444;
    --success: #10b981;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --transition: all 0.3s ease;
}

body.theme-dark {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --secondary: #f472b6;
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --surface: rgba(30, 41, 59, 0.7);
    --surface-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
}

body.theme-dark .list-item,
body.theme-dark .q-builder-card {
    background: var(--surface) !important;
    border-color: var(--surface-border) !important;
}

body.theme-dark input, 
body.theme-dark select, 
body.theme-dark textarea {
    background: rgba(0,0,0,0.3) !important;
    color: #f8fafc !important;
    border-color: rgba(255,255,255,0.2) !important;
}

body.theme-dark input[readonly] {
    background: rgba(255,255,255,0.05) !important;
    color: #94a3b8 !important;
}

body.theme-dark .form-group label {
    color: #e2e8f0 !important;
}

body.theme-dark .exam-option-label {
    border-color: rgba(255,255,255,0.2) !important;
}

body.theme-dark #take-exam-title {
    color: var(--primary) !important;
}

body.theme-ocean {
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --secondary: #06b6d4;
    --bg-gradient-start: #f0f9ff;
    --bg-gradient-end: #e0f2fe;
    --surface: rgba(255, 255, 255, 0.8);
    --surface-border: rgba(255, 255, 255, 0.5);
    --text-main: #0c4a6e;
    --text-muted: #0284c7;
}

body.theme-nature {
    --primary: #10b981;
    --primary-hover: #059669;
    --secondary: #84cc16;
    --bg-gradient-start: #ecfdf5;
    --bg-gradient-end: #d1fae5;
    --surface: rgba(255, 255, 255, 0.8);
    --surface-border: rgba(255, 255, 255, 0.5);
    --text-main: #064e3b;
    --text-muted: #047857;
}

body.theme-corporate {
    --primary: #334155;
    --primary-hover: #1e293b;
    --secondary: #64748b;
    --bg-gradient-start: #f1f5f9;
    --bg-gradient-end: #cbd5e1;
    --surface: rgba(255, 255, 255, 0.9);
    --surface-border: rgba(255, 255, 255, 0.6);
    --text-main: #0f172a;
    --text-muted: #475569;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-main);
    transition: background 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
}

#app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Utilities */
.text-center { text-align: center; }
.mt-4 { margin-top: 1.5rem; }

/* Custom Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}
.modal-overlay.hidden {
    display: none;
    opacity: 0;
}
.hidden {
    display: none !important;
}
.modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-content h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}
.modal-content p {
    color: #4a5568;
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    white-space: pre-wrap;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.mt-4 { margin-top: 1rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.w-100 { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.text-sm { font-size: 0.875rem; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.gradient-text {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Sidebar Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-color);
}

.sidebar {
    width: 260px;
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    box-shadow: 4px 0 15px rgba(0,0,0,0.03);
    z-index: 20;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
}

.sidebar-header h2 {
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    background: transparent;
    border: none;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
}

.nav-item:hover {
    background: rgba(var(--primary-rgb), 0.05);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevent overflow */
}

.top-header {
    background: var(--surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--surface-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    z-index: 10;
}

.content-area {
    padding: 2rem;
    flex: 1;
    overflow-y: auto;
}

/* Glassmorphism */
.glass-card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    font-size: 0.95rem;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
}
.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.23);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(236, 72, 153, 0.39);
}
.btn-secondary:hover {
    background: #db2777;
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.23);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-main);
}
.btn-outline:hover {
    border-color: var(--text-main);
    background: rgba(0,0,0,0.02);
}

.btn-text {
    background: transparent;
    padding: 0.25rem 0.5rem;
}
.btn-text:hover {
    background: rgba(0,0,0,0.05);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.85rem;
}

/* Inputs */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1.5px solid var(--surface-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease-in-out;
    color: var(--text-main);
}
body:not(.theme-dark) input[type="text"], 
body:not(.theme-dark) input[type="email"], 
body:not(.theme-dark) input[type="password"], 
body:not(.theme-dark) input[type="number"], 
body:not(.theme-dark) select {
    border: 1.5px solid #cbd5e1;
    background: #ffffff;
}

input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input[type="number"]:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.input-inline {
    width: auto !important;
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
    display: flex;
    flex-direction: column;
}
.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* Custom Checkbox/Radio */
.option-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    background: rgba(255,255,255,0.5);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: var(--transition);
}
.option-row:hover {
    border-color: #cbd5e1;
}

input[type="radio"] {
    accent-color: var(--primary);
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

/* Layouts */
.role-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.role-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}
@media(min-width: 640px) {
    .role-buttons {
        flex-direction: row;
    }
}

.logo-area {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}
@media(min-width: 800px) {
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.dashboard-content {
    padding: 2rem;
}

/* Question Editor */
.questions-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.question-editor-card {
    background: rgba(255,255,255,0.6);
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    position: relative;
}

/* Lists */
.list-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.list-item {
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid #e2e8f0;
    transition: var(--transition);
}
.list-item:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}
.list-item-info h4 {
    margin-bottom: 0.25rem;
    color: var(--text-main);
}
.badge {
    background: #e0e7ff;
    color: #4338ca;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Exam View */
.exam-question-card {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
}
.exam-question-card:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
.exam-question-card h4 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}
.exam-option-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}
.exam-option-label:hover {
    background: rgba(79, 70, 229, 0.05);
    border-color: #a5b4fc;
}

/* Result View */
.score-container {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto;
}
.score-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.score-ring-bg {
    fill: none;
    stroke: #e2e8f0;
    stroke-width: 8;
}
.score-ring-progress {
    fill: none;
    stroke: url(#grad);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 283; /* 2 * PI * 45 */
    stroke-dashoffset: 283;
    transition: stroke-dashoffset 1.5s ease-out;
}
.score-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: baseline;
}
.score-text span:last-child {
    font-size: 1.25rem;
    color: var(--text-muted);
}


/* Animations */
.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header Actions Styling */
.header-actions {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info-text {
    font-weight: 500;
    color: var(--text-main);
    max-width: 150px;
    line-height: 1.2;
    font-size: 0.95rem;
    text-align: left;
}

.theme-select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

.theme-select option {
    background-color: #ffffff;
    color: #000000;
}

.theme-select:hover {
    background: rgba(0,0,0,0.03);
}

.btn-rounded-outline {
    background: transparent;
    border: 1px solid var(--text-main);
    color: var(--text-main);
    border-radius: 9999px;
    padding: 0.4rem 1.2rem;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-rounded-outline:hover {
    background: rgba(0,0,0,0.05);
}

/* CHAT WIDGET STYLES */
#chat-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--primary);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    border: none;
    z-index: 1000;
    transition: transform 0.2s;
}
#chat-fab:hover { transform: scale(1.1); }
#chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: bold;
}
#chat-widget {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    backdrop-filter: blur(10px);
}
.chat-header {
    background: var(--primary);
    color: white;
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}
.chat-header-actions button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    margin-left: 10px;
}
.chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    word-break: break-word;
}
.chat-msg.mine {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}
.chat-msg.theirs {
    align-self: flex-start;
    background: rgba(0,0,0,0.05);
    color: var(--text-main);
    border-bottom-left-radius: 2px;
}
.chat-msg.system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 12px;
    font-style: italic;
}
.chat-input-area {
    padding: 10px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
    align-items: center;
}
.chat-input-area input[type="text"] {
    flex: 1;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-main);
    outline: none;
}
.chat-send-btn, .chat-icon-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.chat-icon-btn {
    background: rgba(0,0,0,0.05);
    color: var(--text-main);
}
.chat-msg img { max-width: 100%; border-radius: 8px; margin-top: 5px; }

@media print {
    body * { visibility: hidden; }
    #result-details-modal, #result-details-modal * { visibility: visible; }
    #result-details-modal { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; }
    .modal-header-sticky button { display: none; }
    .modal-scrollable-content { overflow: visible !important; height: auto !important; max-height: none !important; }
    .result-modal-container { max-height: none !important; width: 100% !important; overflow: visible !important; box-shadow: none !important; }
}

@media print {
    body { visibility: hidden; background: white; margin: 0; padding: 0; }
    #result-details-modal { visibility: visible; position: absolute; left: 0; top: 0; margin: 0; padding: 0; width: 100%; display: block !important; background: white !important; }
    .result-modal-container { box-shadow: none !important; border: none !important; width: 100% !important; max-width: none !important; margin: 0 !important; padding: 0 !important; max-height: none !important; overflow: visible !important; display: block !important; background: white !important; }
    .modal-scrollable-content { overflow: visible !important; height: auto !important; max-height: none !important; display: block !important; padding: 0 !important; }
    .modal-header-sticky button { display: none !important; }
    .modal-header-sticky { position: static !important; background: white !important; border-bottom: 2px solid #ccc !important; padding: 1rem 0 !important; }
    #rdm-content > div { break-inside: avoid; page-break-inside: avoid; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--surface-border); padding: 1rem; }
    .sidebar-header { margin-bottom: 1rem; }
    .sidebar-nav { flex-direction: row; overflow-x: auto; padding-bottom: 0.5rem; gap: 1rem; }
    .nav-item { flex: 0 0 auto; white-space: nowrap; padding: 0.5rem 1rem; }
    .main-content { padding: 1rem; }
    .top-header { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .header-actions { width: 100%; justify-content: space-between; flex-wrap: wrap; }
    .dashboard-stats { grid-template-columns: 1fr; gap: 1rem; }
    .list-item { flex-direction: column !important; align-items: flex-start !important; gap: 1rem; }
    .list-item > div { width: 100%; }
    .list-item > div:last-child { display: flex; justify-content: flex-end; width: 100%; }
    .q-builder-card .flex-row { flex-direction: column; align-items: stretch; }
    .q-points-input { margin-left: 0 !important; width: 100% !important; }
    .modal-content { width: 95%; padding: 1.5rem; }
    .result-modal-container { width: 100% !important; max-width: 100% !important; max-height: 95vh !important; }
    .modal-header-sticky { flex-direction: column; align-items: flex-start; gap: 1rem; padding: 1rem !important; }
    .modal-header-sticky > div { width: 100%; display: flex; justify-content: space-between; }
    .text-center.mt-8 { margin-top: 1rem; }
}
