:root {
    --cj-bg: #F3F4FA;
    --cj-sidebar: #150F2E;
    --cj-sidebar-hover: #211a44;
    --cj-primary: #5B3FE0;
    --cj-primary-dark: #4227B8;
    --cj-primary-light: #8B6FF0;
    --cj-text: #1B1830;
    --cj-text-light: #6B7280;
    --cj-border: #E6E7F0;
    --cj-white: #FFFFFF;
    --cj-success: #16A34A;
    --cj-danger: #DC2626;
    --cj-warning: #D97706;
    --cj-radius: 14px;
    --cj-shadow: 0 2px 10px rgba(20, 15, 50, 0.06);
    --cj-shadow-lg: 0 12px 32px rgba(20, 15, 50, 0.12);
}

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

body {
    font-family: 'Manrope', 'Segoe UI', Arial, sans-serif;
    background: var(--cj-bg);
    color: var(--cj-text);
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 264px;
    background: var(--cj-sidebar);
    color: #C9C6E8;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform 0.25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 26px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand img { width: 34px; height: auto; flex-shrink: 0; }

.sidebar-brand-text {
    font-weight: 800;
    font-size: 1.125rem;
    color: #fff;
    letter-spacing: 0.2px;
}

.sidebar-brand-text span { color: var(--cj-primary-light); }

.sidebar-nav {
    flex: 1;
    padding: 20px 14px;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6E699C;
    padding: 8px 12px;
    margin-top: 12px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #C9C6E8;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link svg { width: 19px; height: 19px; flex-shrink: 0; }

.sidebar-link:hover {
    background: var(--cj-sidebar-hover);
    color: #fff;
}

.sidebar-link.active {
    background: linear-gradient(135deg, var(--cj-primary), var(--cj-primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px rgba(91, 63, 224, 0.4);
}

.sidebar-footer {
    padding: 16px 14px 22px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---------- Main ---------- */
.main {
    flex: 1;
    margin-left: 264px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    background: var(--cj-white);
    border-bottom: 1px solid var(--cj-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-title h1 {
    font-size: 1.25rem;
    font-weight: 800;
}

.topbar-title p {
    font-size: 0.8125rem;
    color: var(--cj-text-light);
    margin-top: 2px;
}

.menu-toggle-btn {
    display: none;
    background: none;
    border: none;
    padding: 6px;
    color: var(--cj-text);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-user-name {
    font-size: 0.875rem;
    font-weight: 700;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--cj-danger);
    padding: 8px 14px;
    border-radius: 8px;
    background: #FEF2F2;
}

.btn-logout:hover { background: #FEE2E2; }

.content {
    padding: 28px 32px 60px;
    flex: 1;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 8, 30, 0.5);
    z-index: 150;
}

/* ---------- Cards / componentes ---------- */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--cj-white);
    border-radius: var(--cj-radius);
    padding: 22px 24px;
    box-shadow: var(--cj-shadow);
    border: 1px solid var(--cj-border);
}

.stat-card .stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--cj-primary), var(--cj-primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    margin-bottom: 14px;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
}

.stat-card .stat-label {
    font-size: 0.8125rem;
    color: var(--cj-text-light);
    margin-top: 2px;
}

.panel {
    background: var(--cj-white);
    border-radius: var(--cj-radius);
    border: 1px solid var(--cj-border);
    box-shadow: var(--cj-shadow);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--cj-border);
    flex-wrap: wrap;
    gap: 12px;
}

.panel-header h2 {
    font-size: 1.0625rem;
    font-weight: 800;
}

.panel-body { padding: 24px; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 700;
    border: none;
    transition: all 0.15s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--cj-primary), var(--cj-primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px rgba(91, 63, 224, 0.35);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(91, 63, 224, 0.45); }

.btn-secondary {
    background: var(--cj-bg);
    color: var(--cj-text);
    border: 1px solid var(--cj-border);
}

.btn-secondary:hover { background: #E9EAF5; }

.btn-danger-outline {
    background: #fff;
    color: var(--cj-danger);
    border: 1px solid #FCA5A5;
}

.btn-danger-outline:hover { background: #FEF2F2; }

.btn-sm { padding: 7px 12px; font-size: 0.8125rem; }

/* ---------- Tabela ---------- */
table { width: 100%; border-collapse: collapse; }

th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--cj-text-light);
    padding: 12px 24px;
    background: #FAFAFD;
    border-bottom: 1px solid var(--cj-border);
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--cj-border);
    font-size: 0.9375rem;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge-link { background: #EDE9FE; color: #6D28D9; }
.badge-video { background: #FEE2E2; color: #B91C1C; }
.badge-imagem { background: #DBEAFE; color: #1D4ED8; }
.badge-texto { background: #FEF3C7; color: #B45309; }
.badge-links { background: #FFEDD5; color: #C2410C; }
.badge-ativo { background: #DCFCE7; color: #15803D; }
.badge-inativo { background: #F1F1F5; color: #6B7280; }

.slug-pill {
    font-family: 'Courier New', monospace;
    font-size: 0.8125rem;
    background: var(--cj-bg);
    padding: 4px 10px;
    border-radius: 6px;
    color: var(--cj-primary-dark);
    word-break: break-all;
}

.table-empty {
    text-align: center;
    padding: 60px 24px;
    color: var(--cj-text-light);
}

.table-empty svg { color: var(--cj-border); margin-bottom: 12px; }

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

/* ---------- Formulário ---------- */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 700;
    margin-bottom: 7px;
}

.form-hint {
    font-size: 0.8125rem;
    color: var(--cj-text-light);
    margin-top: 6px;
}

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--cj-border);
    border-radius: 10px;
    font-size: 0.9375rem;
    font-family: inherit;
    background: #fff;
    color: var(--cj-text);
}

.form-control:focus {
    outline: none;
    border-color: var(--cj-primary);
    box-shadow: 0 0 0 3px rgba(91, 63, 224, 0.15);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

.tipo-selector {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
}

.tipo-option {
    border: 1.5px solid var(--cj-border);
    border-radius: 10px;
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
}

.tipo-option svg { width: 22px; height: 22px; margin-bottom: 6px; }
.tipo-option span { display: block; font-size: 0.8125rem; font-weight: 700; }

.tipo-option:hover { border-color: var(--cj-primary-light); }

.tipo-option.selected {
    border-color: var(--cj-primary);
    background: #F5F3FF;
    color: var(--cj-primary-dark);
}

.tipo-option input { display: none; }

.fonte-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.fonte-toggle-btn {
    flex: 1;
    padding: 9px;
    text-align: center;
    border: 1.5px solid var(--cj-border);
    border-radius: 8px;
    font-size: 0.8125rem;
    font-weight: 700;
    background: #fff;
    color: var(--cj-text-light);
}

.fonte-toggle-btn.selected {
    border-color: var(--cj-primary);
    background: #F5F3FF;
    color: var(--cj-primary-dark);
}

.alert {
    padding: 13px 16px;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #DCFCE7; color: #15803D; }
.alert-error { background: #FEE2E2; color: #B91C1C; }
.alert-info { background: #EFF6FF; color: #1D4ED8; }

.current-file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--cj-bg);
    border-radius: 10px;
    margin-bottom: 12px;
    font-size: 0.8125rem;
}

.current-file-preview img { width: 42px; height: 42px; object-fit: cover; border-radius: 6px; }

.link-row {
    border: 1.5px solid var(--cj-border);
    border-radius: 10px;
    padding: 10px;
    background: #fff;
    margin-bottom: 10px;
}

.link-row-top {
    display: grid;
    grid-template-columns: 1fr 1.4fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

.link-row-bottom {
    display: flex;
    align-items: center;
    gap: 10px;
}

.link-row-imagem-preview {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    object-fit: cover;
    flex: none;
}

.link-row-imagem-input {
    font-size: 0.8125rem;
    max-width: 200px;
}

.link-row-imagem-hint {
    margin: 0;
}

.link-row-cliques {
    margin-left: auto;
    flex: none;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--cj-primary);
    background: var(--cj-primary-soft, rgba(91,63,224,0.1));
    padding: 3px 9px;
    border-radius: 100px;
    white-space: nowrap;
}

.link-row-remover {
    width: 34px;
    height: 34px;
    border: 1.5px solid var(--cj-border);
    border-radius: 8px;
    background: #fff;
    color: var(--cj-danger);
    font-size: 1.125rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.link-row-remover:hover { border-color: var(--cj-danger); background: #FEF2F2; }

#link-row-adicionar { margin-top: 4px; }

.painel-destaque {
    border-radius: 12px;
    padding: 18px 18px 4px;
    margin-top: 4px;
}

.painel-destaque-links {
    background: #FFF7ED;
    border: 1.5px solid #FED7AA;
}

.cor-fundo-picker {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cor-fundo-picker input[type="color"] {
    width: 52px;
    height: 40px;
    padding: 3px;
    border: 1.5px solid var(--cj-border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
}

.cor-fundo-preview-texto {
    font-family: monospace;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--cj-text-light);
    text-transform: uppercase;
}

.copy-link-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--cj-bg);
    border: 1px dashed var(--cj-border);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.875rem;
}

.copy-link-box code { flex: 1; word-break: break-all; color: var(--cj-primary-dark); font-weight: 700; }

/* ---------- Login ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 20% 20%, #2A1F6B 0%, #150F2E 55%, #0B0820 100%);
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: 20px;
    padding: 40px 36px;
    max-width: 380px;
    width: 100%;
    box-shadow: var(--cj-shadow-lg);
    text-align: center;
}

.login-box img { width: 90px; margin: 0 auto 18px; display: block; }

.login-box h1 { font-size: 1.25rem; font-weight: 800; margin-bottom: 4px; }
.login-box p { font-size: 0.875rem; color: var(--cj-text-light); margin-bottom: 26px; }

.login-box .form-group { text-align: left; }
.login-box .btn-primary { width: 100%; padding: 13px; margin-top: 4px; }

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--cj-shadow-lg);
    }

    .sidebar.open { transform: translateX(0); }

    .sidebar-backdrop.open { display: block; }

    .main { margin-left: 0; }

    .menu-toggle-btn { display: inline-flex; }

    .topbar { padding: 16px 18px; }

    .content { padding: 20px 16px 48px; }

    .form-row { grid-template-columns: 1fr; }

    .tipo-selector { grid-template-columns: repeat(2, 1fr); }

    .link-row-top { grid-template-columns: 1fr; }
    .link-row-remover { justify-self: end; }

    .topbar-user-name { display: none; }
}

@media (max-width: 560px) {
    table thead { display: none; }
    table, tbody, tr, td { display: block; width: 100%; }
    tr { border-bottom: 1px solid var(--cj-border); padding: 12px 0; }
    td { border: none; padding: 6px 0; display: flex; justify-content: space-between; gap: 12px; }
    td::before {
        content: attr(data-label);
        font-weight: 700;
        font-size: 0.75rem;
        color: var(--cj-text-light);
        text-transform: uppercase;
    }
    .table-actions { justify-content: flex-end; }
}
