/* ============================================
   TEMA GLOBAL - Sistema de Templates
   Baseado no estilo de index.html
   ============================================ */

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

:root {
    --app-logo-scale: 1;
}

body {
    font-family: Arial, sans-serif;
    background: #1e1e1e;
    color: #ffffff;
    min-height: 100vh;
}

/* ============ SIDEBAR (lateral esquerda) ============ */
/* Evita "travadinha" no load: sem transição inicial. JS habilita depois. */
html.prefers-sidebar body {
    padding-left: 240px;
}
html.prefers-sidebar.prefers-sidebar-collapsed body {
    padding-left: 64px;
}

body.has-sidebar {
    padding-left: 240px;
}
body.has-sidebar.sidebar-collapsed {
    padding-left: 64px;
}
body.sidebar-transitions.has-sidebar {
    transition: padding-left 0.2s ease;
}

/* Home: sidebar como overlay (não empurra layout) */
body.sidebar-overlay-mode.has-sidebar {
    padding-left: 0 !important;
    transition: none !important;
}
/* Menu inteiro só aparece quando .sidebar-ready (evita flash / meio carregado) */
body.sidebar-overlay-mode .app-sidebar {
    visibility: hidden;
    opacity: 0;
    transform: translateX(-10px);
    will-change: opacity, transform;
    pointer-events: none;
}
body.sidebar-overlay-mode.sidebar-ready .app-sidebar {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}
body.sidebar-overlay-mode.sidebar-transitions .app-sidebar {
    transition: opacity 0.18s ease, transform 0.18s ease, width 0.2s ease;
}

.app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 240px;
    z-index: 900;
    background: #121418;
    border-right: 1px solid #2a2d36;
    display: flex;
    flex-direction: column;
    transition: none;
}
body.sidebar-transitions .app-sidebar {
    transition: width 0.2s ease;
}

.app-sidebar.collapsed {
    width: 64px;
}

.sidebar-header {
    flex-shrink: 0;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid #2a2d36;
    min-height: 56px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0;
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.2px;
    overflow: hidden;
    white-space: nowrap;
    margin-left: 20px;
}

.sidebar-brand.brand-loading .sidebar-brand-icon,
.sidebar-brand.brand-loading .sidebar-brand-text {
    visibility: hidden;
}

.sidebar-brand-logo {
    display: none;
    width: auto;
    height: calc(56px * var(--app-logo-scale));
    object-fit: contain;
}

.sidebar-brand.has-image .sidebar-brand-logo {
    display: block;
}

.sidebar-brand.has-image .sidebar-brand-icon,
.sidebar-brand.has-image .sidebar-brand-text {
    display: none;
}

.topbar .brand.brand-loading span {
    visibility: hidden;
}

.topbar .brand img.app-brand-logo {
    display: none;
    width: auto;
    height: calc(44px * var(--app-logo-scale));
    object-fit: contain;
}

.topbar .brand.has-image img.app-brand-logo {
    display: block;
}

.topbar .brand.has-image span {
    display: none;
}

.sidebar-brand-icon {
    color: #e50914;
}

.sidebar-brand-text {
    color: #c9d2dc;
}

.app-sidebar.collapsed .sidebar-brand-text {
    display: none;
}

.sidebar-toggle {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e222b;
    border: 1px solid #2a2d36;
    border-radius: 0;
    color: #c9d2dc;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s, color 0.2s;
}

.sidebar-toggle:hover {
    background: #2a2d36;
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 0;
    color: #c9d2dc;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s, color 0.2s;
    border: none;
    background: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-family: inherit;
}

.sidebar-link:hover {
    background: #1e222b;
    color: #fff;
}

.sidebar-link.active {
    background: rgba(229, 9, 20, 0.15);
    color: #fff;
}

.sidebar-icon {
    flex-shrink: 0;
    width: 24px;
    text-align: center;
    font-size: 16px;
}

.sidebar-label {
    overflow: hidden;
    white-space: nowrap;
}

.app-sidebar.collapsed .sidebar-label {
    display: none;
}

.app-sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 10px;
}

.sidebar-footer {
    flex-shrink: 0;
    padding: 12px 8px;
    border-top: 1px solid #2a2d36;
}

.sidebar-footer .sidebar-link {
    color: #999;
}

.sidebar-footer .sidebar-link:hover {
    color: #fff;
}

/* ============ LAYOUT ============ */
.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.page-header {
    background: #2d2d2d;
    padding: 24px 28px;
    border-radius: 0;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.page-header p {
    color: #999;
    font-size: 14px;
    margin-top: 4px;
}

.page-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ============ BOTÕES ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
    color: white;
    background: #007acc;
}

.btn:hover {
    background: #0090f0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 122, 204, 0.4);
}

.btn:active {
    transform: translateY(0);
}

/* Variantes */
.btn-secondary {
    background: #3a3a3a;
    color: #ccc;
}
.btn-secondary:hover {
    background: #4a4a4a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-success {
    background: #27ae60;
}
.btn-success:hover {
    background: #2ecc71;
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.4);
}

.btn-danger {
    background: #c0392b;
}
.btn-danger:hover {
    background: #e74c3c;
    box-shadow: 0 4px 12px rgba(192, 57, 43, 0.4);
}

.btn-purple {
    background: #8e44ad;
}
.btn-purple:hover {
    background: #a855c5;
    box-shadow: 0 4px 12px rgba(142, 68, 173, 0.4);
}

.btn-warning {
    background: #e67e22;
    color: #fff;
}
.btn-warning:hover {
    background: #f39c12;
    box-shadow: 0 4px 12px rgba(230, 126, 34, 0.4);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 0;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
    border-radius: 0;
}

.btn:disabled {
    background: #3a3a3a;
    color: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============ CARDS ============ */
.card {
    background: #2d2d2d;
    border-radius: 0;
    padding: 20px;
    transition: all 0.2s ease;
}

.card:hover {
    background: #333;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: #007acc;
    margin-bottom: 8px;
}

.card-meta {
    font-size: 12px;
    color: #777;
    margin-bottom: 12px;
}

.card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============ GRID ============ */
.grid {
    display: grid;
    gap: 16px;
}

.grid-2 { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

/* ============ BADGES ============ */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-system {
    background: #3a3a3a;
    color: #999;
}

.badge-primary {
    background: rgba(0, 122, 204, 0.2);
    color: #007acc;
}

/* ============ INPUTS ============ */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #ccc;
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    background: #1e1e1e;
    border: 2px solid #444;
    border-radius: 0;
    color: #fff;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: #007acc;
}

.form-input::placeholder {
    color: #666;
}

.search-input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    background: #1e1e1e;
    border: 2px solid #444;
    border-radius: 0;
    color: #fff;
    font-size: 14px;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #007acc;
}

.search-wrapper {
    position: relative;
}

.search-wrapper::before {
    content: "🔍";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
}

/* ============ TABS ============ */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.tab {
    padding: 8px 18px;
    border: none;
    border-radius: 0;
    background: #2d2d2d;
    color: #999;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover { background: #3a3a3a; color: #ccc; }
.tab.active { background: #007acc; color: #fff; }

/* ============ MODALS ============ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

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

.modal-box {
    background: #2d2d2d;
    border-radius: 0;
    padding: 28px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-box h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #fff;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ============ NOTIFICATIONS ============ */
.notification {
    position: fixed;
    top: 24px;
    right: 24px;
    background: #27ae60;
    color: white;
    padding: 14px 22px;
    border-radius: 0;
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    z-index: 2000;
    font-weight: 600;
    font-size: 14px;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
}

.notification.error {
    background: #c0392b;
}

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #666;
}

.empty-state-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-state h2 {
    font-size: 20px;
    color: #999;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: #666;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1e1e1e; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #007acc; }

/* ============ UTILITÁRIOS ============ */
.text-muted { color: #777; }
.text-primary { color: #007acc; }
.text-success { color: #27ae60; }
.text-danger { color: #c0392b; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

input[type="file"] { display: none; }

/* ============ Barra de progresso global (rodapé) ============ */
.global-progress-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 99999;
    pointer-events: none;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.15);
    opacity: 0;
    transition: opacity 0.2s ease;
}
.global-progress-bar.active {
    opacity: 1;
}
.global-progress-bar .global-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 28%;
    max-width: 120px;
    background: linear-gradient(90deg, transparent, rgba(39, 174, 96, 0.9), transparent);
    border-radius: 0 2px 2px 0;
    animation: global-progress-slide 1.4s ease-in-out infinite;
}
.global-progress-bar.completing .global-progress-fill {
    animation: none;
    width: 100%;
    max-width: none;
    background: rgba(39, 174, 96, 0.75);
    transition: width 0.25s ease-out;
}
.global-progress-bar.completing {
    transition: opacity 0.3s ease 0.25s;
}
.global-progress-bar.completing.hide {
    opacity: 0;
}
@keyframes global-progress-slide {
    0% { transform: translateX(-100%); }
    60% { transform: translateX(400%); }
    100% { transform: translateX(400%); }
}

/* ============ Lightbox imagem (tamanho original + zoom) ============ */
.image-lightbox-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}
.image-lightbox-overlay.show {
    opacity: 1;
    visibility: visible;
}
/* Área expandida (quase tela inteira): imagem 100% cabe no verde, com pretos em cima/baixo */
.image-lightbox-overlay .image-lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.image-lightbox-overlay .image-lightbox-img-wrap {
    width: 90vw;
    height: calc(90vh - 56px);
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: #000;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.image-lightbox-overlay .image-lightbox-img-wrap::-webkit-scrollbar { width: 0; height: 0; }
/* Preview/recorte: sem bordas, igual ao download */
.image-lightbox-overlay.crop-size .image-lightbox-img-wrap {
    padding: 0;
}
/* Imagem sempre contida: espaços pretos em cima/baixo ou laterais (letterboxing) */
.image-lightbox-overlay .image-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    transition: transform 0.15s ease;
}
.image-lightbox-overlay .image-lightbox-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 8px 16px;
    background: rgba(40, 40, 40, 0.95);
    border-radius: 0;
}
.image-lightbox-overlay .image-lightbox-zoom-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 0;
    background: #333;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
}
.image-lightbox-overlay .image-lightbox-zoom-btn:hover {
    background: #007acc;
}
.image-lightbox-overlay .image-lightbox-zoom-label {
    font-size: 13px;
    color: #aaa;
    min-width: 52px;
    text-align: center;
}
.image-lightbox-overlay .image-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(60, 60, 60, 0.9);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}
.image-lightbox-overlay .image-lightbox-close:hover {
    background: #c0392b;
}
.image-lightbox-overlay .image-lightbox-title {
    font-size: 13px;
    color: #999;
    max-width: 80vw;
    text-align: center;
    margin-top: 4px;
}
