/* =========================================================
   DESIGN HUB V2 - TEMA GLOBAL MODERNIZADO
   ========================================================= */
:root {
    --bg-app: #0f172a; 
    --bg-card: rgba(30, 41, 59, 0.65); 
    --bg-input: rgba(15, 23, 42, 0.8); 
    --border-color: rgba(255, 255, 255, 0.1); 
    --text-main: #f8fafc; 
    --text-muted: #94a3b8; 
    --sidebar-width: 420px; 
    --header-height: 70px;
    --primary-color: #3b82f6; 
    --primary-hover: #2563eb;
    --secondary-color: #06b6d4; 
    --box-color: #1e293b;
    --danger-color: #ef4444; 
    --warning-color: #eab308;
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-blur: blur(12px);
    --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);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Plus Jakarta Sans', sans-serif; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent; }
body { background-color: var(--bg-app); color: var(--text-main); height: 100vh; display: flex; flex-direction: column; overflow: hidden; margin: 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }

/* CABEÇALHO GLOBAL */
.main-header { 
    height: var(--header-height); 
    background: var(--glass-bg); 
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-bottom: 1px solid var(--border-color); 
    display: flex; align-items: center; justify-content: space-between; padding: 0 32px; z-index: 100; 
}
.logo-brand { display: flex; align-items: center; gap: 12px; }
.logo-brand svg { color: var(--primary-color); }
.logo-brand h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.btn-secondary, .btn-back { 
    background: rgba(255, 255, 255, 0.05); 
    border: 1px solid var(--border-color); 
    color: var(--text-main); 
    padding: 10px 18px; 
    border-radius: 10px; 
    font-weight: 600; 
    font-size: 0.9rem;
    text-decoration: none; 
    display: inline-flex; align-items: center; gap: 8px; 
    transition: all 0.3s ease; 
}
.btn-secondary:hover, .btn-back:hover { 
    background: rgba(255, 255, 255, 0.1); 
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

/* LAYOUT DO HUB (INDEX) */
.main-container { display: flex; flex: 1; height: calc(100vh - var(--header-height)); overflow: hidden; }
.sidebar { 
    width: var(--sidebar-width); 
    background: var(--glass-bg); 
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color); 
    padding: 28px; 
    display: flex; flex-direction: column; gap: 28px; 
    overflow-y: auto; z-index: 10; 
}
.workspace { 
    flex: 1; padding: 40px; overflow-y: auto; display: flex; flex-direction: column; 
    background: radial-gradient(circle at top, #1e293b 0%, #0f172a 100%); 
}

/* LAYOUT DE CONFIGURAÇÕES (CONFIG) */
body.config-page { padding: 40px; height: auto; overflow: auto; background: var(--bg-app); }
body.config-page .main-header { padding: 0; border: none; background: transparent; backdrop-filter: none; margin-bottom: 40px; height: auto; }
.config-container { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; max-width: 1400px; margin: 0 auto; align-items: start; }
.config-col { display: flex; flex-direction: column; gap: 40px; }

/* COMPONENTES COMPARTILHADOS (CARDS, FORMS, BOTÕES) */
.section-title { font-size: 0.8rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 14px; letter-spacing: 0.05em; }
.config-group { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 12px; padding: 20px; display: flex; flex-direction: column; gap: 16px; box-shadow: var(--shadow-sm); backdrop-filter: blur(8px); }
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px; padding: 32px; backdrop-filter: blur(8px); box-shadow: var(--shadow-md); transition: transform 0.3s ease, box-shadow 0.3s ease; }
.card:hover { box-shadow: var(--shadow-lg); }
.card h2 { margin-bottom: 28px; font-size: 1.4rem; font-weight: 700; border-bottom: 1px solid var(--border-color); padding-bottom: 16px; display: flex; align-items: center; gap: 12px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { margin-bottom: 24px; }
.form-group.full-width { grid-column: span 2; }
.form-group label, .input-label-row { display: block; font-size: 0.85rem; font-weight: 700; color: var(--text-muted); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.02em; }
.form-control, .file-control, .editor-input, .editor-textarea, select.form-control { 
    width: 100%; background: var(--bg-input); border: 1px solid var(--border-color); 
    border-radius: 10px; color: #fff; padding: 14px 16px; font-size: 0.95rem; outline: none; 
    transition: all 0.2s ease; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}
.form-control:focus, .editor-input:focus, .editor-textarea:focus, select.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25), inset 0 2px 4px rgba(0,0,0,0.1);
}
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 40px; }
.editor-textarea { resize: vertical; min-height: 100px; }
.file-control { padding: 11px 16px; cursor: pointer; color: var(--text-muted); }
.file-control::-webkit-file-upload-button { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.1); padding: 8px 16px; border-radius: 8px; color: #fff; cursor: pointer; margin-right: 12px; font-weight: 600; transition: background 0.2s; }
.file-control::-webkit-file-upload-button:hover { background: rgba(255,255,255,0.15); }

.info-text { font-size: 0.75rem; color: var(--warning-color); display: block; margin-top: 6px; }
.checkbox-group { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.checkbox-label { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; cursor: pointer; font-weight: 600; background: rgba(255,255,255,0.03); padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border-color); transition: all 0.2s ease;}
.checkbox-label:hover { background: rgba(255,255,255,0.06); }
.sidebar .checkbox-label { background: transparent; border: none; padding: 0; }
.sidebar .checkbox-label:hover { background: transparent; }
.checkbox-label input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary-color); }

.btn-submit { 
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: #fff; border: none; padding: 18px 24px; border-radius: 10px; font-weight: 700; 
    cursor: pointer; width: 100%; margin-top: 10px; font-size: 1.1rem; 
    transition: all 0.3s ease; box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4); 
}
.btn-submit:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6); }
.btn-submit:active { transform: translateY(0); }

/* LISTAS E BADGES */
.list-item { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-color); padding: 20px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; transition: transform 0.2s ease, background 0.2s ease; }
.list-item:hover { background: rgba(255, 255, 255, 0.05); transform: translateX(4px); }
.list-item-info strong { display: block; margin-bottom: 6px; font-size: 1.15rem; color: #fff; font-weight: 700; }
.list-item-info span { font-size: 0.85rem; color: var(--text-muted); display: block; margin-bottom: 4px;}
.badge { background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 600; margin-right: 6px; display: inline-block; margin-top: 8px; color: #fff; border: 1px solid rgba(255,255,255,0.05); }
.btn-group { display: flex; gap: 10px; }
.btn-edit, .btn-delete { border-radius: 8px; padding: 10px 16px; font-weight: 700; font-size: 0.9rem; cursor: pointer; transition: all 0.2s ease; }
.btn-edit { background: rgba(234, 179, 8, 0.1); color: var(--warning-color); border: 1px solid rgba(234, 179, 8, 0.3); }
.btn-edit:hover { background: rgba(234, 179, 8, 0.2); transform: translateY(-1px); }
.btn-delete { background: rgba(239, 68, 68, 0.1); color: var(--danger-color); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-delete:hover { background: rgba(239, 68, 68, 0.2); transform: translateY(-1px); }

/* SELETORES DE MARCA E FORMATO (HUB) */
.brand-grid, .format-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.brand-card, .format-card { 
    background: rgba(255, 255, 255, 0.03); 
    border: 1px solid var(--border-color); 
    border-radius: 10px; padding: 14px 6px; 
    display: flex; flex-direction: column; align-items: center; 
    cursor: pointer; text-align: center; transition: all 0.2s ease; 
}
.brand-card:hover, .format-card:hover { background: rgba(255, 255, 255, 0.06); border-color: rgba(255,255,255,0.2); transform: translateY(-2px); }
.brand-card img { width: 32px; height: 32px; margin-bottom: 8px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); }
.brand-card span, .format-card span { font-size: 11px; font-weight: 700; color: var(--text-muted); letter-spacing: 0.02em; }
.brand-card.active, .format-card.active { 
    border-color: var(--primary-color); 
    background: rgba(59, 130, 246, 0.1); 
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2); 
    transform: translateY(-2px);
}
.format-card.active span { color: #ffffff; }

.format-icon { border: 2px solid var(--text-muted); border-radius: 6px; transition: all 0.2s ease; margin-bottom: 8px; }
.format-card.active .format-icon { border-color: var(--primary-color); background: rgba(59, 130, 246, 0.25); box-shadow: 0 0 10px rgba(59, 130, 246, 0.3); }
.ratio-9-16 { width: 20px; height: 36px; }
.ratio-4-5 { width: 26px; height: 32px; }
.ratio-1-1 { width: 30px; height: 30px; }

.upload-zone { 
    border: 2px dashed rgba(255,255,255,0.2); 
    background: rgba(255, 255, 255, 0.02); 
    border-radius: 12px; padding: 32px 20px; text-align: center; 
    cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 12px; 
    transition: all 0.3s ease; font-weight: 600; font-size: 0.95rem; color: var(--text-muted);
}
.upload-zone:hover { 
    border-color: var(--primary-color); 
    background: rgba(59, 130, 246, 0.05); 
    color: #fff;
}

/* ÁREA DE RENDERIZAÇÃO DO HUB */
.previews-container { display: flex; flex-wrap: wrap; justify-content: center; gap: 40px; width: 100%; align-items: flex-start; }
.post-wrapper { display: flex; flex-direction: column; gap: 16px; flex: 1; min-width: 280px; max-width: 380px; transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.hidden-format { position: absolute !important; visibility: hidden !important; opacity: 0 !important; pointer-events: none !important; z-index: -999 !important; width: 0 !important; height: 0 !important; overflow: hidden !important; margin: 0 !important; padding: 0 !important; flex: 0 !important; min-width: 0 !important; max-width: 0 !important; }

.post-header-label { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.btn-download { 
    background-color: rgba(255,255,255,0.1); color: #ffffff; border: 1px solid rgba(255,255,255,0.1); 
    padding: 8px 14px; border-radius: 8px; font-weight: 700; cursor: pointer; 
    text-transform: uppercase; font-size: 0.75rem; transition: all 0.2s ease; 
}
.btn-download:hover { background-color: var(--primary-color); border-color: var(--primary-color); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3); }

.svg-canvas { 
    position: relative; width: 100%; 
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8); 
    border-radius: 16px; background: #000; overflow: hidden; display: flex; align-items: center; justify-content: center; 
    border: 1px solid rgba(255,255,255,0.05);
}
.scale-wrapper { position: relative; width: 1080px; height: 1920px; flex-shrink: 0; transform-origin: center center; }

.highlight { color: var(--secondary-color); font-family: inherit; } 
.loader { color: var(--text-muted); font-size: 1rem; text-align: center; padding: 40px; width: 100%; font-weight: 500; }

/* MODAIS */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; align-items: center; justify-content: center; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.modal-content { 
    background: var(--bg-app); border: 1px solid var(--border-color); border-radius: 16px; 
    padding: 36px; width: 90%; max-width: 600px; max-height: 90vh; overflow-y: auto; 
    position: relative; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8); 
}
.modal-close { position: absolute; top: 24px; right: 24px; font-size: 1.8rem; cursor: pointer; color: var(--text-muted); background: none; border: none; transition: color 0.2s; line-height: 1; }
.modal-close:hover { color: #fff; }
.modal-content h2 { margin-bottom: 28px; border-bottom: 1px solid var(--border-color); padding-bottom: 16px; font-size: 1.4rem; font-weight: 800; }
.btn-update { background: linear-gradient(135deg, #f59e0b, #d97706); color: #fff; box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4); }
.btn-update:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245, 158, 11, 0.6); }

/* RESPONSIVIDADE MOBILE */
@media (max-width: 900px) {
    body { height: auto; overflow: auto; }
    .main-header, body.config-page .main-header { padding: 0 20px; height: 64px; margin-bottom: 20px; }
    .logo-brand h1 { font-size: 1.15rem; }
    .btn-secondary, .btn-back { padding: 8px 12px; font-size: 0.85rem; }
    
    .main-container { flex-direction: column; height: auto; overflow: visible; }
    .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); padding: 24px 20px; overflow: visible; }
    .workspace { padding: 24px 20px; overflow: visible; }
    .brand-grid, .format-grid { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
    .post-wrapper { max-width: 100%; margin-bottom: 24px; } 

    .config-container { grid-template-columns: 1fr; gap: 24px; }
    body.config-page { padding: 24px 20px; }
    .form-row { grid-template-columns: 1fr; }
    .form-group.full-width { grid-column: span 1; }
}

/* =========================================================
   NOVAS CLASSES: MINIATURAS DE TEMPLATES E COLLAB
   ========================================================= */
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.template-card { background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border-color); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; align-items: center; cursor: pointer; text-align: center; transition: all 0.2s ease; }
.template-card:hover { border-color: rgba(255,255,255,0.2); transform: translateY(-2px); background: rgba(255, 255, 255, 0.06); }
.template-card.active { border-color: var(--primary-color); background: rgba(59, 130, 246, 0.1); box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2); transform: translateY(-2px); }

/* A miniatura 4:5 minimalista */
.template-thumb { width: 100%; aspect-ratio: 4/5; background: rgba(0,0,0,0.4); border-radius: 6px; margin-bottom: 10px; border: 1px dashed rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; font-size: 1.4rem; transition: all 0.2s ease; }
.template-card:hover .template-thumb { border-color: rgba(255,255,255,0.3); }
.template-card.active .template-thumb { border-color: var(--primary-color); background: rgba(59, 130, 246, 0.15); color: var(--primary-color); border-style: solid; }
.template-card span { font-size: 10px; font-weight: 700; color: var(--text-muted); line-height: 1.3; word-break: break-word; letter-spacing: 0.02em; }
.template-card.active span { color: #fff; }

/* View do Collab Ativo na Sidebar */
.collab-active-view { display: none; align-items: center; justify-content: space-between; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); padding: 12px 16px; border-radius: 10px; margin-top: 12px; transition: all 0.2s ease; }
.collab-active-info { display: flex; align-items: center; gap: 12px; }
.collab-active-info img { width: 28px; height: 28px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2)); }
.collab-active-info span { font-size: 0.95rem; font-weight: 700; color: #fff; }
.btn-change-collab { background: none; border: none; color: var(--primary-color); cursor: pointer; font-size: 0.8rem; font-weight: 800; text-transform: uppercase; transition: color 0.2s; letter-spacing: 0.05em; }
.btn-change-collab:hover { color: var(--primary-hover); }

/* =========================================================
   UX MELHORADO NAS LISTAGENS (CONFIGURAÇÕES)
   ========================================================= */
.list-item-content { display: flex; align-items: flex-start; gap: 20px; }

/* Ícones e Cores das Marcas */
.list-brand-icon { width: 48px; height: 48px; object-fit: contain; background: rgba(255,255,255,0.03); border-radius: 10px; padding: 8px; border: 1px solid rgba(255,255,255,0.1); flex-shrink: 0; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.color-dots-container { display: flex; gap: 8px; margin-top: 10px; }
.color-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.2); display: inline-block; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }

/* Miniatura e Ícones no Template */
.list-template-thumb { width: 40px; height: 50px; background: rgba(0,0,0,0.4); border-radius: 6px; border: 1px dashed rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.allowed-brands-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center;}
.allowed-brand-icon { width: 24px; height: 24px; object-fit: contain; background: rgba(255,255,255,0.05); border-radius: 6px; padding: 3px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 2px 4px rgba(0,0,0,0.15);}