/* -----------------------------------------
   Eduktiva AI Studio - Modern Theme
----------------------------------------- */
:root {
    --ed-bg-main: #f4f7f9;
    --ed-bg-card: #ffffff;
    --ed-header-bg: #111827;
    --ed-header-text: #ffffff;
    --ed-primary: #5A4FCF;
    --ed-primary-hover: #4a40bd;
    --ed-danger: #ef4444;
    --ed-danger-hover: #dc2626;
    --ed-success: #4ade80;
    --ed-border: #e5e7eb;
    --ed-text-main: #1f2937;
    --ed-text-muted: #6b7280;
    --ed-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    --ed-radius-card: 15px;
    --ed-radius-inner: 8px;
    --ed-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.eduktiva-modern-theme {
    width: 100%;
    background: var(--ed-bg-main) !important;
    padding: 40px 20px;
    font-family: var(--ed-font);
    color: var(--ed-text-main);
    box-sizing: border-box;
}

.eduktiva-modern-theme * {
    box-sizing: border-box;
}

/* Top Bar & Credits */
.eduktiva-top-bar {
    max-width: 1200px;
    margin: 0 auto 20px auto;
    display: flex;
    justify-content: flex-end;
}

.eduktiva-credits-pill {
    background: var(--ed-bg-card);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: var(--ed-shadow);
    font-size: 14px;
    font-weight: 600;
    color: var(--ed-text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.eduktiva-credit-dot {
    width: 10px;
    height: 10px;
    background-color: var(--ed-primary);
    border-radius: 50%;
    display: inline-block;
}

/* Grid Layout */
.eduktiva-grid {
    display: grid !important;
    grid-template-columns: 350px 1fr !important;
    gap: 30px !important;
    align-items: start !important;
    max-width: 1200px;
    margin: 0 auto;
}

.eduktiva-col-left {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.eduktiva-col-right {
    min-width: 0; /* Previene que el contenido rompa el Grid */
}

/* Cards Base */
.eduktiva-card, .eduktiva-result-card, .eduktiva-history-card {
    background: var(--ed-bg-card);
    border-radius: var(--ed-radius-card);
    box-shadow: var(--ed-shadow);
    overflow: hidden;
}

/* Form Styles */
.eduktiva-card-header {
    background: var(--ed-header-bg);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.eduktiva-card-header h2 {
    color: var(--ed-header-text);
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.eduktiva-badge {
    background: var(--ed-primary);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.eduktiva-form-scroll {
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.eduktiva-fieldset {
    border: 1px solid var(--ed-border);
    border-radius: var(--ed-radius-inner);
    padding: 15px;
    margin-bottom: 20px;
    background: #fdfdfd;
}

.eduktiva-fieldset legend {
    font-size: 14px;
    font-weight: 600;
    color: var(--ed-primary);
    background: var(--ed-bg-card);
    padding: 0 10px;
    border: 1px solid var(--ed-border);
    border-radius: 4px;
}

.eduktiva-field {
    margin-bottom: 15px;
}

.eduktiva-field:last-child {
    margin-bottom: 0;
}

.eduktiva-field-row {
    display: flex;
    gap: 15px;
}

.eduktiva-field-row .eduktiva-field {
    flex: 1;
}

.eduktiva-modern-theme label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--ed-text-muted);
}

.eduktiva-modern-theme input[type="text"],
.eduktiva-modern-theme select,
.eduktiva-modern-theme textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--ed-border);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s;
}

.eduktiva-modern-theme input[type="text"]:focus,
.eduktiva-modern-theme select:focus,
.eduktiva-modern-theme textarea:focus {
    border-color: var(--ed-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(90, 79, 207, 0.1);
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: normal;
    color: var(--ed-text-main);
    margin-bottom: 8px;
    cursor: pointer;
}

.eduktiva-form-footer {
    padding: 0 20px 20px;
}

button#btn_generar {
    background: var(--ed-primary);
    color: #ffffff;
    border: none;
    padding: 15px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--ed-radius-inner);
    cursor: pointer;
    transition: background-color 0.3s;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

button#btn_generar:hover {
    background: var(--ed-primary-hover);
}

button#btn_generar:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* History Card */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid var(--ed-border);
}

.history-header h3 {
    margin: 0;
    font-size: 13px;
    color: var(--ed-text-muted);
    font-weight: 600;
}

.history-header .badge {
    background: #eef2ff;
    color: var(--ed-primary);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    font-weight: bold;
}

.history-body {
    padding: 20px;
    text-align: center;
}

.history-body p {
    color: #9ca3af;
    font-size: 13px;
    font-style: italic;
    margin: 0;
}

/* Results Panel */
.eduktiva-result-card {
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

.result-header {
    background: var(--ed-header-bg);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    background-color: #9ca3af; /* Default pending state */
    border-radius: 50%;
    transition: background-color 0.3s;
}

.result-header h2 {
    margin: 0;
    font-size: 16px;
    color: var(--ed-header-text);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.eduktiva-actions {
    display: flex;
    gap: 10px;
}

.btn-export {
    color: #ffffff;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-export:hover {
    opacity: 0.9;
}

.btn-export.pdf { background: var(--ed-danger); }
.btn-export.docx { background: var(--ed-primary); }

.result-body {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
}

/* Empty State */
#eduktiva-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex: 1;
    color: var(--ed-text-muted);
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

#eduktiva-empty-state h3 {
    font-size: 18px;
    margin: 0 0 8px 0;
    color: var(--ed-text-main);
}

#eduktiva-empty-state p {
    margin: 0;
    font-size: 14px;
}

/* Loading State */
#eduktiva-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    flex: 1;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top: 4px solid var(--ed-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#eduktiva-loading h3 {
    color: var(--ed-primary);
    font-size: 16px;
    margin: 0;
}

/* ==========================================================================
   ESTILOS DEL RESULTADO MARKDOWN (.prose)
   ========================================================================== */
#eduktiva-result-content {
    background-color: #ffffff !important;
    color: #333333;
    line-height: 1.6 !important;
    padding: 20px;
}

.prose {
    font-size: 1rem;
    line-height: 1.6;
    color: #374151;
    max-width: 100%;
    overflow-wrap: break-word;
}
.prose h1, .prose h2, .prose h3 {
    color: #111827;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}
.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.125rem; }
.prose p, .prose ul, .prose ol { margin-bottom: 1.25em; }
.prose ul { list-style-type: disc; padding-left: 1.5em; }
.prose ol { list-style-type: decimal; padding-left: 1.5em; }
.prose li { margin-bottom: 0.5em; }
.prose strong { font-weight: 600; color: #111827; }

/* Tablas */
.prose table { border-collapse: collapse; width: 100%; page-break-inside: auto; table-layout: fixed; word-wrap: break-word; overflow-wrap: break-word; margin-top: 1em; margin-bottom: 1.5em; }
.prose tr { page-break-inside: avoid; page-break-after: auto; }
.prose th, .prose td {
    padding: 0.75rem;
    text-align: left;
    border: 1px solid #e5e7eb;
    word-wrap: break-word;
    vertical-align: top;
}
.prose th { background-color: #f3f4f6; }

@media (max-width: 900px) {
    .eduktiva-grid {
        grid-template-columns: 1fr !important;
    }
}

@media print {
    body * { visibility: hidden; }
    #eduktiva-result-content, #eduktiva-result-content * { visibility: visible; }
    #eduktiva-result-content { position: absolute; left: 0; top: 0; width: 100%; }
    .no-print, .eduktiva-unit-action { display: none !important; }
}
