/* ============================================
   WB Manager — Design System
   Font: JetBrains Mono + Syne
   Theme: Cyberpunk-Industrial Dark/Light
   ============================================ */

:root {
    --bg-primary: #0a0c10;
    --bg-secondary: #10131a;
    --bg-tertiary: #181c26;
    --bg-card: #12151e;
    --bg-hover: #1e2334;
    --border: #232840;
    --border-bright: #2e3455;
    --text-primary: #e8eaf6;
    --text-secondary: #8892b0;
    --text-muted: #4a5278;
    --accent: #00d4ff;
    --accent-dim: rgba(0,212,255,0.15);
    --accent-glow: rgba(0,212,255,0.4);
    --green: #00ff88;
    --red: #ff3860;
    --orange: #ff8c42;
    --purple: #b48eff;
    --yellow: #ffd700;
    --sidebar-w: 240px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.4);
    --font-mono: 'JetBrains Mono', monospace;
    --font-display: 'Syne', sans-serif;
    --transition: 0.2s ease;
}

[data-theme="light"] {
    --bg-primary: #f0f2f8;
    --bg-secondary: #e8eaf2;
    --bg-tertiary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #e2e5f0;
    --border: #d0d4e8;
    --border-bright: #b8bed8;
    --text-primary: #1a1e32;
    --text-secondary: #4a5278;
    --text-muted: #8892b0;
    --accent: #0066cc;
    --accent-dim: rgba(0,102,204,0.1);
    --accent-glow: rgba(0,102,204,0.3);
    --green: #00a854;
    --red: #e0001a;
    --shadow: 0 4px 24px rgba(0,0,0,0.1);
}

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

body {
    font-family: var(--font-mono);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 13px;
    line-height: 1.6;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: width var(--transition);
    overflow: hidden;
}

.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-details,
.sidebar.collapsed .sidebar-footer-actions a[title="Perfil"],
.sidebar.collapsed .sidebar-footer-actions a[title="Sair"] { display: none; }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px 16px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    white-space: nowrap;
}

.logo-icon {
    color: var(--accent);
    font-size: 22px;
    line-height: 1;
    animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sidebar-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    transition: all var(--transition);
    flex-shrink: 0;
}
.sidebar-toggle:hover { color: var(--accent); border-color: var(--accent); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.nav-section { margin-bottom: 20px; }

.nav-label {
    font-size: 9px;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 8px;
    display: block;
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
    position: relative;
}

.nav-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--accent-dim);
    color: var(--accent);
    border-left: 2px solid var(--accent);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: #fff;
    flex-shrink: 0;
}

.user-details {
    min-width: 0;
    flex: 1;
}

.user-name {
    display: block;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.sidebar-footer-actions {
    display: flex;
    gap: 4px;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    text-decoration: none;
}
.btn-icon svg { width: 14px; height: 14px; }
.btn-icon:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }

/* ── Main Content ── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left var(--transition);
}

.sidebar.collapsed ~ .main-content { margin-left: 56px; }

.topbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; }
.topbar-time { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.mobile-menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius);
    cursor: pointer;
}
.mobile-menu-btn svg { width: 16px; height: 16px; }

.content-area { padding: 24px; flex: 1; }

/* ── Cards & Grid ── */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-bright); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-title {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* ── Stat Cards ── */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), border-color var(--transition);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--stat-color, var(--accent));
    opacity: 0.8;
}

.stat-card:hover { transform: translateY(-2px); border-color: var(--border-bright); }

.stat-number {
    font-family: var(--font-display);
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stat-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    background: var(--accent-dim);
    color: var(--accent);
    margin-top: 8px;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn svg { width: 14px; height: 14px; }

.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover { filter: brightness(1.2); box-shadow: 0 0 20px var(--accent-glow); }

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

.btn-danger {
    background: rgba(255,56,96,0.15);
    color: var(--red);
    border: 1px solid rgba(255,56,96,0.3);
}
.btn-danger:hover { background: rgba(255,56,96,0.25); }

.btn-success {
    background: rgba(0,255,136,0.15);
    color: var(--green);
    border: 1px solid rgba(0,255,136,0.3);
}
.btn-success:hover { background: rgba(0,255,136,0.25); }

.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 12px;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

textarea.form-control { resize: vertical; min-height: 120px; }

select.form-control {
    cursor: pointer;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238892b0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

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

/* ── Tables ── */
.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-toolbar {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--bg-tertiary);
    padding: 10px 14px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

td {
    padding: 10px 14px;
    font-size: 12px;
    color: var(--text-primary);
    max-width: 300px;
}

.td-mono { font-family: var(--font-mono); }
.td-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-whitelist { background: rgba(0,255,136,0.15); color: var(--green); }
.badge-blacklist { background: rgba(255,56,96,0.15); color: var(--red); }
.badge-admin { background: rgba(180,142,255,0.15); color: var(--purple); }
.badge-collaborator { background: rgba(0,212,255,0.15); color: var(--accent); }

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 8px;
}

.pagination-links { display: flex; gap: 4px; }

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    transition: all var(--transition);
}

.page-link:hover, .page-link.active {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Alerts / Toast ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert-success { background: rgba(0,255,136,0.1); border: 1px solid rgba(0,255,136,0.3); color: var(--green); }
.alert-error { background: rgba(255,56,96,0.1); border: 1px solid rgba(255,56,96,0.3); color: var(--red); }
.alert-info { background: var(--accent-dim); border: 1px solid rgba(0,212,255,0.3); color: var(--accent); }
.alert-warning { background: rgba(255,140,66,0.1); border: 1px solid rgba(255,140,66,0.3); color: var(--orange); }

#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    max-width: 320px;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
    font-size: 12px;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Tabs ── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-link {
    padding: 10px 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    margin-bottom: -1px;
}
.tab-link:hover { color: var(--text-primary); }
.tab-link.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Login Page ── */
.login-page {
    min-height: 100vh;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
}

.login-bg {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 20% 50%, rgba(0,212,255,0.05) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 20%, rgba(180,142,255,0.05) 0%, transparent 60%);
    pointer-events: none;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    position: relative;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 8px;
}

.login-logo .logo-text {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
}

/* ── Dashboard Specific ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.chart-container { position: relative; height: 260px; }

/* ── Color dot ── */
.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ── Checkbox & Radio ── */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    transition: all var(--transition);
}

.checkbox-label:hover { border-color: var(--accent); color: var(--accent); }
.checkbox-label input[type="checkbox"] { accent-color: var(--accent); }

/* ── Filter Bar ── */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}

.filter-bar .form-group { margin-bottom: 0; min-width: 140px; flex: 1; }
.filter-bar .btn { flex-shrink: 0; align-self: flex-end; }

/* ── Section Header ── */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.section-title {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
}

/* ── Switch ── */
.switch-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 12px;
}
.switch {
    position: relative;
    width: 40px;
    height: 22px;
}
.switch input { display: none; }
.switch-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 22px;
    transition: background var(--transition);
}
.switch-slider::before {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    left: 3px; top: 3px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--transition);
}
.switch input:checked + .switch-slider { background: var(--accent); }
.switch input:checked + .switch-slider::before { transform: translateX(18px); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-bright); }

/* ── Responsive ── */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-w) !important;
    }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow); }
    .main-content { margin-left: 0 !important; }
    .mobile-menu-btn { display: flex; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-grid { grid-template-columns: 1fr; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .content-area { padding: 16px; }
    .table-toolbar { flex-direction: column; align-items: stretch; }
}

/* ── Misc ── */
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 11px; }
.fw-bold { font-weight: 700; }
.mono { font-family: var(--font-mono); }
hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.tag-list-type { display: inline-flex; align-items: center; gap: 4px; }
.dot-white { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.dot-black { width: 6px; height: 6px; border-radius: 50%; background: var(--red); }
