/* ===== Variables & Reset ===== */
:root {
    --primary: #005482;
    --primary-hover: #0e192e;
    --accent: #14aa9c;
    --error: #dc2626;
    --warning: #d97706;
    --text: #0c304f;
    --text-muted: #64748b;
    --bg: #e9edf2;
    --surface: #ffffff;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --hover: #f1f5f9;
    --active: #eff6ff;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    --radius: 8px;
    --radius-sm: 6px;

    --c-ispring: #2563eb;
    --c-storyline: #7c3aed;
    --c-captivate: #ea580c;
    --c-genially: #e11d48;
    --c-rise: #16a34a;
    --c-vanilla: #0891b2;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 160px;
    right: 0;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    display: flex;
    align-items: center;
}

.tabs-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 1rem;
    gap: 1rem;
}

.tabs {
    display: flex;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    align-items: center;
    min-height: 36px;
}

.tabs::-webkit-scrollbar { height: 4px; }
.tabs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

.tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
    min-width: 140px;
    max-width: 280px;
    transition: all 0.15s ease;
    font-size: 0.85rem;
}

.tab:hover { background: var(--hover); }

.tab.active {
    background: var(--surface);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tab-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    color: var(--text);
}

.tab-format {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    letter-spacing: 0.4px;
}

.tab-format.tab-format-ispring { background: var(--c-ispring); }
.tab-format.tab-format-storyline { background: var(--c-storyline); }
.tab-format.tab-format-captivate { background: var(--c-captivate); }
.tab-format.tab-format-genially { background: var(--c-genially); }
.tab-format.tab-format-rise { background: var(--c-rise); }
.tab-format.tab-format-vanilla { background: var(--c-vanilla); }

.tab-standard,
.scorm-badge {
    font-size: 0.62rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    color: #475569;
    background: #e2e8f0;
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.tab-close {
    display: flex; align-items: center; justify-content: center;
    width: 18px; height: 18px;
    border: none; background: none; border-radius: 50%;
    cursor: pointer; opacity: 0.6;
    transition: all 0.15s ease;
}

.tab-close:hover { opacity: 1; background: rgba(0,0,0,0.08); }
.tab-close svg { width: 11px; height: 11px; }

.header-actions { display: flex; gap: 8px; flex-shrink: 0; }

.action-button {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    height: 34px; padding: 0 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}

.action-button:hover:not(:disabled) { background: var(--primary-hover); }
.action-button:disabled { background: #94a3b8; cursor: not-allowed; opacity: 0.6; }
.action-button svg { width: 16px; height: 16px; }

.action-button-secondary {
    background: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border-strong);
}
.action-button-secondary:hover:not(:disabled) { background: var(--hover); border-color: var(--primary); color: var(--primary); }
.action-button-secondary:disabled { background: var(--surface); color: #94a3b8; border-color: var(--border); }

/* ===== Layout ===== */
.main-wrapper {
    display: grid;
    grid-template-columns: 160px 64px 1fr;
    height: 100vh;
}

/* ===== Left Sidebar ===== */
.left-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem 0.75rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100vh;
}

.sidebar-logo {
    display: none; /* Temporariamente oculto; preserva o markup para reativação. */
    margin-bottom: 1rem;
    text-align: center;
    width: 100%;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.logo { height: 32px; width: auto; }

.upload-section { margin-top: 0.5rem; width: 100%; }

.upload-area {
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius);
    padding: 1rem 0.75rem;
    text-align: center;
    background: var(--bg);
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 1rem;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: var(--active);
}

.upload-content { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.upload-icon { width: 28px; height: 28px; color: var(--primary); }
.upload-text { font-size: 0.8rem; color: var(--text); font-weight: 500; line-height: 1.3; }
.upload-text strong { color: var(--primary); }
.upload-hint { font-size: 0.65rem; color: var(--text-muted); margin-top: 0.25rem; line-height: 1.3; }

/* ===== Main Content ===== */
.main-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    padding-top: 52px;
}

.content-area { flex: 1; overflow-y: auto; padding: 0.75rem 1rem; }

.no-content {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    height: 100%; text-align: center;
    color: var(--text-muted);
    gap: 0.5rem;
}

.no-content svg { width: 4rem; height: 4rem; opacity: 0.4; }
.no-content h3 { color: var(--text); font-weight: 600; margin-top: 0.5rem; }
.no-content p { font-size: 0.9rem; }

.formats-list {
    list-style: none;
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    text-align: left;
}

.formats-list li {
    display: flex; align-items: center; gap: 0.6rem;
    font-size: 0.85rem; color: var(--text-muted);
}

.formats-list code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--text);
    border: 1px solid var(--border);
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    min-width: 80px;
    text-align: center;
}

.badge-ispring { background: var(--c-ispring); }
.badge-storyline { background: var(--c-storyline); }
.badge-captivate { background: var(--c-captivate); }
.badge-genially { background: var(--c-genially); }
.badge-rise { background: var(--c-rise); }
.badge-vanilla { background: var(--c-vanilla); }


/* ===== Slide Content ===== */
.slide-content { height: 100%; display: flex; flex-direction: column; }

.slide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
    flex-wrap: wrap;
}

.slide-header-left { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.slide-header h2 { color: var(--primary); font-size: 1rem; font-weight: 600; }

.format-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 2px 8px;
    border-radius: 4px;
    color: white;
}
.format-badge.format-ispring { background: var(--c-ispring); }
.format-badge.format-storyline { background: var(--c-storyline); }
.format-badge.format-captivate { background: var(--c-captivate); }
.format-badge.format-genially { background: var(--c-genially); }
.format-badge.format-rise { background: var(--c-rise); }
.format-badge.format-vanilla { background: var(--c-vanilla); }

.slide-nav { display: flex; align-items: center; gap: 0.5rem; }

.nav-btn {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
}

.nav-btn:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.nav-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.nav-btn svg { width: 14px; height: 14px; }

#slideCounter {
    font-weight: 500; color: var(--text-muted);
    font-size: 0.8rem; min-width: 48px; text-align: center;
}

.slide-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
}

.text-section, .media-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    background: var(--surface);
}

.text-section h4, .media-section h4 {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
}

.text-content {
    color: var(--text);
    line-height: 1.65;
    font-size: 0.95rem;
}

.text-content h2, .text-content h3 { color: var(--primary); margin: 0.75rem 0 0.5rem; }
.text-content h2 { font-size: 1.1rem; }
.text-content h3 { font-size: 1rem; }
.text-content p { margin-bottom: 0.6rem; }
.text-content ul, .text-content ol { margin: 0.5rem 0 0.75rem 1.25rem; }
.text-content li { margin-bottom: 0.3rem; }
.text-content.empty { color: var(--text-muted); font-style: italic; }

.media-gallery { display: block; }

.media-layout {
    display: grid;
    grid-template-columns: 64px 1fr;
    gap: 0.75rem;
    align-items: stretch;
}

.media-thumbs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 4px;
}

.media-thumbs::-webkit-scrollbar { width: 5px; }
.media-thumbs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.media-thumb {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.media-thumb:hover { border-color: var(--border-strong); }
.media-thumb.active { border-color: var(--primary); }

.media-thumb img, .media-thumb video {
    width: 100%; height: 100%;
    object-fit: cover;
}

.media-thumb.is-placeholder {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-align: center;
    padding: 4px;
    overflow: hidden;
    word-break: break-word;
    line-height: 1.2;
}

.media-preview {
    min-height: 320px;
    max-height: 480px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    overflow: auto;
    position: relative;
}

.media-item {
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: default;
}

.media-item img, .media-item video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.media-placeholder {
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 1rem;
    text-align: center;
    gap: 0.5rem;
}

.media-placeholder svg { width: 2rem; height: 2rem; margin-bottom: 0.4rem; }



/* ===== Slides Sidebar (slide list) ===== */
.right-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 0.5rem 0.25rem;
    padding-top: 60px;
    overflow-y: auto;
    height: 100vh;
}

.slides-list h3 { display: none; }

.slides-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.slide-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--surface);
    width: 40px;
    height: 40px;
}

.slide-item:hover {
    background: var(--hover);
    border-color: var(--primary);
}

.slide-item.active {
    background: var(--active);
    border-color: var(--primary);
    border-width: 2px;
}

.slide-number { font-weight: 600; color: var(--primary); font-size: 0.8rem; }

/* ===== Progress ===== */
.progress-area {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.progress-bar {
    width: 100%;
    height: 5px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    word-break: break-word;
}

/* ===== Status (toast) ===== */
.status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.85rem;
    z-index: 1001;
    max-width: 400px;
    box-shadow: var(--shadow);
    display: none;
}

.status.success { background-color: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.status.error { background-color: #fee2e2; color: var(--error); border: 1px solid #fecaca; }
.status.warning { background-color: #fef3c7; color: var(--warning); border: 1px solid #fde68a; }
.status.info { background-color: var(--active); color: var(--primary); border: 1px solid #bfdbfe; }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .main-wrapper { grid-template-columns: 140px 56px 1fr; }
    .app-header { left: 140px; }
}

@media (max-width: 900px) {
    .main-wrapper { grid-template-columns: 1fr; }
    .left-sidebar, .right-sidebar { display: none; }
    .app-header { left: 0; }
    .action-button span { display: none; }
}



/* ===== OCR (Tesseract.js) ===== */
.media-item-image {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 100%;
    max-height: 100%;
}

.media-image-wrap {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-sm);
    max-width: 100%;
    max-height: 420px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
}

.media-image-wrap img {
    max-width: 100%;
    max-height: 420px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.ocr-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 84, 130, 0.85);
    color: #fff;
    font-weight: 700;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    opacity: 1;
    transition: background 0.15s ease, transform 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.ocr-btn:hover { background: var(--primary); transform: scale(1.05); }
.ocr-btn.ocr-done { background: var(--accent); }
.ocr-btn.ocr-done:hover { background: #0f8d81; }

.media-item.ocr-active {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 0;
    background: transparent;
    cursor: default;
    width: 100%;
    max-width: 100%;
}

.media-item.ocr-active .media-image-wrap {
    max-height: 260px;
    border: 1px solid var(--border);
}

.media-item.ocr-active .media-image-wrap img { max-height: 260px; }

.ocr-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    font-size: 0.85rem;
    color: var(--text);
}

.ocr-panel[hidden] { display: none; }

.ocr-state { display: flex; flex-direction: column; gap: 10px; min-height: 100%; }

.ocr-prompt { margin: 0; font-size: 0.9rem; }
.ocr-lang {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.ocr-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: auto;
}

.ocr-btn-primary, .ocr-btn-secondary {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.ocr-btn-primary { background: var(--primary); color: #fff; }
.ocr-btn-primary:hover { background: var(--primary-hover); }

.ocr-btn-secondary {
    background: var(--surface);
    color: var(--primary);
    border-color: var(--border-strong);
}
.ocr-btn-secondary:hover { background: var(--hover); border-color: var(--primary); }

.ocr-loading-head { display: flex; align-items: center; gap: 10px; }

.ocr-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: ocr-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes ocr-spin { to { transform: rotate(360deg); } }

.ocr-status { color: var(--text-muted); font-size: 0.8rem; }

.ocr-progress {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.ocr-progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.2s ease;
}

.ocr-result-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.ocr-tag {
    background: var(--accent);
    color: #fff;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.62rem;
    letter-spacing: 0.4px;
}

.ocr-result-text {
    width: 100%;
    min-height: 100px;
    max-height: 220px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    background: var(--bg);
    color: var(--text);
    white-space: pre-wrap;
}

.ocr-empty {
    margin: 0;
    padding: 8px 10px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
    background: var(--bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}

.ocr-error p {
    margin: 0;
    color: var(--error);
    font-size: 0.85rem;
}

.text-content .ocr-appended {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border);
    color: var(--text);
}

@media (max-width: 720px) {
    .media-layout { grid-template-columns: 56px 1fr; }
    .media-item.ocr-active .media-image-wrap { max-height: 180px; }
    .media-item.ocr-active .media-image-wrap img { max-height: 180px; }
}
