/* ===== VARIABLES ===== */
:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1e1e2e;
    --sidebar-hover: #2a2a3e;
    --sidebar-active: #6366f1;
    --sidebar-text: #a0a0b8;
    --sidebar-text-active: #ffffff;
    --topbar-height: 60px;
    --content-bg: #f4f6fb;
    --card-bg: #ffffff;
    --card-radius: 12px;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.06);
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
}

[data-dark="1"] {
    --content-bg: #0f172a;
    --card-bg: #1e293b;
    --border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* ===== RESET ===== */
* { box-sizing: border-box; }
body { background: var(--content-bg); font-family: 'Inter', system-ui, sans-serif; color: var(--text-primary); margin: 0; }

/* ===== LAYOUT ===== */
.admin-wrapper { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand .brand-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 1.1rem; color: #fff;
}

.sidebar-section {
    padding: 1rem 1.5rem 0.25rem;
    font-size: 0.65rem; font-weight: 700;
    letter-spacing: 1.5px; text-transform: uppercase;
    color: rgba(255,255,255,0.25);
}

.sidebar-nav { flex: 1; padding: 0.5rem 0; overflow-y: auto; }

.sidebar-link {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem; font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap; overflow: hidden;
}

.sidebar-link i { font-size: 1rem; flex-shrink: 0; width: 20px; text-align: center; color: var(--sidebar-text); }
.sidebar-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-active); border-left-color: var(--primary); }
.sidebar-link:hover i { color: var(--sidebar-text-active); }
.sidebar-link.active { background: rgba(99,102,241,0.12); color: var(--sidebar-text-active); border-left-color: var(--sidebar-active); }
.sidebar-link.active i { color: var(--sidebar-active); }

/* ===== MAIN ===== */
.admin-main { margin-left: var(--sidebar-width); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-height);
    background: #1e1e2e;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.75rem; gap: 1rem;
    position: sticky; top: 0; z-index: 50;
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.topbar-title { font-size: 1rem; font-weight: 600; color: #fff; flex: 1; }

/* Topbar actions group */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.topbar-icon-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.12);
    background: none;
    color: rgba(255,255,255,0.5);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.topbar-icon-btn:hover { background: rgba(99,102,241,0.2); color: #a5b4fc; border-color: rgba(99,102,241,0.4); }

/* Theme picker */
.topbar-theme-picker { position: relative; }

.theme-picker-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 200px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    padding: 0.875rem;
    z-index: 200;
    opacity: 0; visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.theme-picker-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }

.theme-picker-title {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.theme-picker-divider { height: 1px; background: var(--border); margin: 0.75rem 0; }

.theme-swatches { display: flex; flex-wrap: wrap; gap: 6px; }

.theme-swatch,
.theme-sidebar-swatch {
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
    padding: 0;
}
.theme-swatch:hover,
.theme-sidebar-swatch:hover { transform: scale(1.15); }
.theme-swatch.active,
.theme-sidebar-swatch.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--card-bg), 0 0 0 4px var(--primary); }

/* Dark mode overrides */
[data-dark="1"] body { background: var(--content-bg); color: var(--text-primary); }
[data-dark="1"] .p-card,
[data-dark="1"] .chart-card,
[data-dark="1"] .stat-card { background: var(--card-bg); border-color: var(--border); }
[data-dark="1"] .p-card-header { background: rgba(255,255,255,0.03); }
[data-dark="1"] table.dataTable thead th { background: #1e293b; color: var(--text-secondary); border-color: var(--border); }
[data-dark="1"] table.dataTable tbody td { border-color: var(--border); color: var(--text-primary); }
[data-dark="1"] table.dataTable tbody tr:hover td { background: rgba(255,255,255,0.04); }
[data-dark="1"] .topbar-icon-btn { border-color: rgba(255,255,255,0.12); color: rgba(255,255,255,0.5); }
[data-dark="1"] .p-btn-secondary { background: #334155; color: var(--text-primary); }
[data-dark="1"] .p-card-footer { background: rgba(255,255,255,0.02); border-color: var(--border); }
[data-dark="1"] .stat-card { background: var(--card-bg); border-color: var(--border); }
[data-dark="1"] .theme-picker-dropdown { background: var(--card-bg); border-color: var(--border); }
[data-dark="1"] .theme-picker-title { color: var(--text-secondary); }
[data-dark="1"] .ts-control { background: var(--card-bg) !important; border-color: var(--border) !important; color: var(--text-primary) !important; }
[data-dark="1"] .ts-dropdown { background: var(--card-bg) !important; border-color: var(--border) !important; }
[data-dark="1"] .ts-dropdown .ts-option,
[data-dark="1"] .ts-dropdown .option { color: var(--text-primary) !important; }
[data-dark="1"] .ts-dropdown .ts-option:hover,
[data-dark="1"] .ts-dropdown .option:hover { background: rgba(255,255,255,0.06) !important; }
[data-dark="1"] .form-control,
[data-dark="1"] .form-select,
[data-dark="1"] input[type="text"]:not(.ts-control *),
[data-dark="1"] input[type="email"],
[data-dark="1"] input[type="number"],
[data-dark="1"] input[type="password"],
[data-dark="1"] textarea,
[data-dark="1"] select:not(.ts-initialized) {
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}
[data-dark="1"] label { color: var(--text-secondary); }
[data-dark="1"] .p-modal-header { border-color: var(--border); }
[data-dark="1"] .modal-content { background: var(--card-bg); border-color: var(--border); }
[data-dark="1"] .modal-footer { border-color: var(--border); }
[data-dark="1"] .nav-tabs { border-color: var(--border); }
[data-dark="1"] .nav-tabs .nav-link { color: var(--text-secondary); }
[data-dark="1"] .nav-tabs .nav-link.active { color: var(--primary); }
[data-dark="1"] .p-alert-success { background: #14532d; color: #86efac; border-color: #166534; }
[data-dark="1"] .p-alert-danger { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
[data-dark="1"] .p-alert-warning { background: #451a03; color: #fcd34d; border-color: #78350f; }
[data-dark="1"] .dataTables_wrapper .dataTables_filter input,
[data-dark="1"] .dataTables_wrapper .dataTables_length select { background: var(--card-bg); border-color: var(--border); color: var(--text-primary); }
[data-dark="1"] .dataTables_wrapper .dataTables_info { color: var(--text-secondary); }
[data-dark="1"] .dataTables_wrapper .dataTables_paginate .paginate_button { border-color: var(--border) !important; color: var(--text-secondary) !important; }
[data-dark="1"] .page-content { background: var(--content-bg); }
[data-dark="1"] .admin-main { background: var(--content-bg); }

.topbar-breadcrumb {
    font-size: 0.8rem; color: rgba(255,255,255,0.45);
    display: flex; align-items: center; gap: 0.4rem;
}
.topbar-breadcrumb a { color: rgba(255,255,255,0.45); text-decoration: none; }
.topbar-breadcrumb a:hover { color: #a5b4fc; }

/* ===== TOPBAR USER DROPDOWN ===== */
#userDropdown { position: relative; }

.topbar-user-btn {
    display: flex; align-items: center; gap: 0.625rem;
    background: none; border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px; padding: 0.4rem 0.75rem 0.4rem 0.4rem;
    cursor: pointer; transition: background 0.2s, border-color 0.2s;
}
.topbar-user-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(99,102,241,0.4); }

.topbar-avatar {
    width: 32px; height: 32px; background: var(--primary);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.8rem; font-weight: 700; flex-shrink: 0;
}
.topbar-avatar-img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }

.topbar-user-info { display: flex; flex-direction: column; text-align: left; }
.topbar-user-name { font-size: 0.82rem; font-weight: 600; color: #fff; line-height: 1.2; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user-role { font-size: 0.7rem; color: rgba(255,255,255,0.45); }
.topbar-chevron { font-size: 0.7rem; color: rgba(255,255,255,0.45); transition: transform 0.2s; }

.topbar-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 240px; background: var(--card-bg);
    border: 1px solid var(--border); border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    z-index: 200; opacity: 0; visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.topbar-dropdown.open { opacity: 1; visibility: visible; transform: translateY(0); }

.topbar-dropdown-header { display: flex; align-items: center; gap: 0.75rem; padding: 1rem 1rem 0.75rem; }
.topbar-dropdown-avatar { width: 40px; height: 40px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1rem; font-weight: 700; flex-shrink: 0; }
.topbar-dropdown-avatar-img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.topbar-dropdown-name { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.topbar-dropdown-email { font-size: 0.75rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.topbar-dropdown-divider { height: 1px; background: var(--border); margin: 0.25rem 0; }
.topbar-dropdown-item { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 1rem; font-size: 0.85rem; color: var(--text-primary); text-decoration: none; transition: background 0.15s; }
.topbar-dropdown-item:hover { background: #f8fafc; color: var(--primary); }
.topbar-dropdown-item i { font-size: 0.9rem; width: 16px; text-align: center; color: var(--text-secondary); }
.topbar-dropdown-item:hover i { color: var(--primary); }
.topbar-dropdown-item-danger { color: var(--danger) !important; }
.topbar-dropdown-item-danger:hover { background: #fff5f5 !important; color: var(--danger) !important; }
.topbar-dropdown-item-danger i { color: var(--danger) !important; }
.topbar-dropdown-item:last-child { border-radius: 0 0 12px 12px; }

/* ===== PAGE CONTENT ===== */
.page-content { padding: 1.75rem; flex: 1; }

/* ===== CARDS ===== */
.p-card { background: var(--card-bg); border-radius: var(--card-radius); box-shadow: var(--card-shadow); border: 1px solid var(--border); }

.p-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    background: linear-gradient(135deg, rgba(99,102,241,0.03), transparent);
}
.p-card-title { font-size: 0.95rem; font-weight: 600; color: var(--text-primary); margin: 0; }
.p-card-title i { color: var(--primary); margin-right: 0.4rem; }
.p-card-body { padding: 1.5rem; }

.p-card-footer {
    padding: .875rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    background: rgba(0,0,0,0.01);
}

/* ===== STAT CARDS ===== */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border);
    padding: 1.5rem;
    display: flex; align-items: center; gap: 1.25rem;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.stat-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 0.25rem; }
.stat-link { margin-left: auto; font-size: 0.75rem; color: var(--primary); text-decoration: none; white-space: nowrap; }
.stat-link:hover { text-decoration: underline; }

/* ===== BUTTONS ===== */
.p-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 1rem; border-radius: 8px;
    font-size: 0.85rem; font-weight: 500;
    border: none; cursor: pointer; text-decoration: none;
    transition: opacity 0.2s, transform 0.1s; white-space: nowrap;
}
.p-btn:hover { opacity: 0.88; transform: translateY(-1px); color: inherit; }
.p-btn:active { transform: translateY(0); }
.p-btn-primary { background: var(--primary); color: #fff; }
.p-btn-success { background: var(--success); color: #fff; }
.p-btn-warning { background: var(--warning); color: #fff; }
.p-btn-danger { background: var(--danger); color: #fff; }
.p-btn-info { background: var(--info); color: #fff; }
.p-btn-secondary { background: #e2e8f0; color: var(--text-primary); }
.p-btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.p-btn-outline { background: transparent; border: 1px solid currentColor; }
.p-btn-outline.p-btn-primary { color: var(--primary); }
.p-btn-outline.p-btn-danger { color: var(--danger); }
.p-btn-outline.p-btn-warning { color: var(--warning); }

/* ===== INPUTS ===== */
.form-control,
.form-select,
input[type="text"]:not(.ts-control *),
input[type="email"],
input[type="number"],
input[type="password"],
textarea,
select:not(.ts-initialized) {
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 0.55rem 0.875rem !important;
    font-size: 0.875rem !important;
    color: var(--text-primary) !important;
    background: #fff !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
    outline: none !important;
    width: 100%;
}

.form-control:focus,
.form-select:focus,
input[type="text"]:not(.ts-control *):focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
textarea:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1) !important;
}

.form-control.is-invalid,
input.is-invalid { border-color: var(--danger) !important; }

/* Input interno do TomSelect — sem herdar estilos globais */
.ts-control input,
.ts-control input[type="text"] {
    border: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    width: auto !important;
    min-width: 60px !important;
    outline: none !important;
    height: auto !important;
}

/* Input-group — corrigir border-radius */
.input-group .form-control,
.input-group input[type="text"]:not(.ts-control *),
.input-group input[type="number"],
.input-group input[type="email"],
.input-group input[type="password"] {
    border-radius: 0 !important;
    flex: 1;
}
.input-group > *:first-child,
.input-group > .form-control:first-child { border-radius: 8px 0 0 8px !important; }
.input-group > *:last-child,
.input-group > .form-control:last-child { border-radius: 0 8px 8px 0 !important; }
.input-group-text {
    border: 1px solid var(--border);
    background: #f8fafc;
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 0.55rem 0.875rem;
    border-radius: 8px 0 0 8px;
}

/* Input file */
input[type="file"] {
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 0.4rem 0.75rem !important;
    font-size: 0.875rem !important;
    color: var(--text-primary) !important;
    background: #fff !important;
    width: 100%;
    cursor: pointer;
}
input[type="file"]::-webkit-file-upload-button {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.78rem;
    cursor: pointer;
    margin-right: 0.5rem;
}

/* Garantir que img nunca herde width 100% dos inputs */
img { width: auto !important; max-width: 100%; }
.img-preview-box img,
.favicon-preview-box img,
.upload-preview { width: 100% !important; height: 100% !important; object-fit: contain; }
    padding: 0.25rem !important;
    height: 40px !important;
    width: 60px !important;
    cursor: pointer;
}

label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.35rem; display: block; }
label i.pi { font-size: inherit; color: inherit; }
.invalid-feedback { font-size: 0.78rem; color: var(--danger); margin-top: 0.25rem; }

/* Garantir que ícones PrimeIcons nunca sejam afetados por estilos globais */
.pi {
    font-family: 'primeicons' !important;
    font-style: normal !important;
    font-weight: normal !important;
    display: inline-block !important;
    width: auto !important;
    height: auto !important;
    line-height: 1 !important;
    speak: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== TOM SELECT ===== */
.ts-wrapper { width: 100%; }

.ts-control {
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 0.4rem 0.625rem !important;
    font-size: 0.875rem !important;
    min-height: 40px !important;
    background: #fff !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    align-items: center !important;
    cursor: text !important;
}

.ts-wrapper.focus .ts-control {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1) !important;
    outline: none !important;
}

.ts-item {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    border: 1px solid rgba(99,102,241,0.2) !important;
    border-radius: 6px !important;
    padding: 2px 6px 2px 8px !important;
    font-size: 0.78rem !important;
    font-weight: 500 !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 4px !important;
    line-height: 1.4 !important;
}

.ts-item .remove {
    color: var(--primary) !important;
    opacity: 0.5;
    font-size: 0.9rem !important;
    cursor: pointer !important;
    padding: 0 2px !important;
}
.ts-item .remove:hover { opacity: 1 !important; }

.ts-dropdown {
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.1) !important;
    font-size: 0.875rem !important;
    margin-top: 4px !important;
    overflow: hidden !important;
    z-index: 9999 !important;
}

.ts-dropdown-content { max-height: 220px !important; overflow-y: auto !important; }

.ts-dropdown .ts-option,
.ts-dropdown .option {
    padding: 0.55rem 0.875rem !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.625rem !important;
    cursor: pointer !important;
    transition: background 0.15s !important;
    color: var(--text-primary) !important;
}

.ts-dropdown .ts-option:hover,
.ts-dropdown .option:hover {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

.ts-dropdown .ts-option.selected,
.ts-dropdown .option.selected {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    font-weight: 500 !important;
}

.ts-dropdown .ts-option.active,
.ts-dropdown .option.active { background: #f8fafc !important; }

.tomselect-checkbox {
    width: 15px !important;
    height: 15px !important;
    min-width: 15px !important;
    border: 1.5px solid var(--border) !important;
    border-radius: 4px !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    background: #fff !important;
    cursor: pointer !important;
    position: relative !important;
    transition: all 0.15s !important;
    padding: 0 !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
}

.ts-dropdown .ts-option.selected .tomselect-checkbox,
.ts-dropdown .option.selected .tomselect-checkbox {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
}

.ts-dropdown .ts-option.selected .tomselect-checkbox::after,
.ts-dropdown .option.selected .tomselect-checkbox::after {
    content: '' !important;
    position: absolute !important;
    left: 4px !important;
    top: 1px !important;
    width: 5px !important;
    height: 9px !important;
    border: 2px solid #fff !important;
    border-top: none !important;
    border-left: none !important;
    transform: rotate(45deg) !important;
}

.ts-no-results { padding: 0.875rem; color: var(--text-secondary); font-size: 0.85rem; text-align: center; }

/* ===== TABELA SIMPLES (sem DataTables) ===== */
[data-dark="1"] .dt-wrapper table thead th { background: #1e293b; color: var(--text-secondary); border-color: var(--border); }
[data-dark="1"] .dt-wrapper table tbody td { border-color: var(--border); color: var(--text-primary); }
[data-dark="1"] .dt-wrapper table tbody tr:nth-child(odd) td { background: #1e293b; }
[data-dark="1"] .dt-wrapper table tbody tr:nth-child(even) td { background: #162032; }
[data-dark="1"] .dt-wrapper table tbody tr:hover td { background: rgba(99,102,241,0.08) !important; }

/* ===== DATATABLE ===== */
.dt-wrapper { overflow-x: auto; padding: 1rem 1.5rem 1.5rem; }
table.dataTable { width: 100% !important; border-collapse: collapse; }
table.dataTable thead th {
    background: #f8fafc; color: var(--text-secondary);
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.6px; padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--border); white-space: nowrap;
    cursor: pointer; user-select: none;
}
table.dataTable thead th:hover { background: #f1f5f9; color: var(--primary); }
table.dataTable thead th.sorting_asc::after { content: ' ↑'; color: var(--primary); }
table.dataTable thead th.sorting_desc::after { content: ' ↓'; color: var(--primary); }
table.dataTable tbody td { padding: 0.75rem 1rem; font-size: 0.875rem; color: var(--text-primary); border-bottom: 1px solid var(--border); vertical-align: middle; }
table.dataTable tbody tr:nth-child(even) td { background: rgba(99,102,241,0.02); }
table.dataTable tbody tr:hover td { background: var(--primary-light) !important; }
table.dataTable tbody tr:last-child td { border-bottom: none; }
table.dataTable td.text-muted, table.dataTable th.text-muted { color: var(--text-secondary) !important; }

.dataTables_wrapper { padding: 0; }
.dataTables_wrapper .dt-top { padding: 0 0 0.875rem; }
.dataTables_wrapper .dt-bottom { padding: 0.875rem 0 0; border-top: 1px solid var(--border); }
.dataTables_wrapper .dataTables_filter input { border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.75rem; font-size: 0.85rem; outline: none; transition: border-color 0.2s; width: auto !important; }
.dataTables_wrapper .dataTables_filter input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.dataTables_wrapper .dataTables_length select { border: 1px solid var(--border); border-radius: 8px; padding: 0.35rem 0.5rem; font-size: 0.85rem; width: auto !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button { border-radius: 6px !important; padding: 0.3rem 0.65rem !important; font-size: 0.82rem !important; border: 1px solid var(--border) !important; margin: 0 2px !important; color: var(--text-secondary) !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button.current { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }
.dataTables_wrapper .dataTables_paginate .paginate_button:hover:not(.current) { background: var(--primary-light) !important; border-color: var(--primary) !important; color: var(--primary) !important; }
.dataTables_wrapper .dataTables_info { font-size: 0.82rem; color: var(--text-secondary); }
[data-dark="1"] table.dataTable tbody tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
[data-dark="1"] table.dataTable tbody tr:hover td { background: rgba(99,102,241,0.08) !important; }

/* ===== BADGES ===== */
.p-badge { display: inline-flex; align-items: center; gap: .4rem; padding: 0.3rem 0.75rem; border-radius: 50px; font-size: 0.82rem; font-weight: 700; }
.p-badge .pi { font-size: .72rem; }
.p-badge-primary { background: var(--primary-light); color: var(--primary); }
.p-badge-success { background: #dcfce7; color: #16a34a; }
.p-badge-warning { background: #fef3c7; color: #d97706; }
.p-badge-danger { background: #fee2e2; color: #dc2626; }
.p-badge-secondary { background: #f1f5f9; color: var(--text-secondary); }

/* ===== ALERTS ===== */
.p-alert { padding: 0.875rem 1.25rem; border-radius: 10px; font-size: 0.875rem; display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.p-alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.p-alert-danger { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.p-alert-warning { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }

/* ===== MODAL ===== */
.p-modal-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.p-modal-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }

/* ===== CHART CARDS ===== */
.chart-card { background: var(--card-bg); border-radius: var(--card-radius); box-shadow: var(--card-shadow); border: 1px solid var(--border); padding: 1.5rem; height: 100%; }
.chart-card-title { font-size: 0.9rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.25rem; }
.chart-card-subtitle { font-size: 0.78rem; color: var(--text-secondary); margin-bottom: 1.25rem; }
.chart-container { position: relative; }

/* ===== GRID RESPONSIVO ===== */
.grid { display: flex; flex-wrap: wrap; margin: -0.5rem; }
.grid > [class*="col-"] { padding: 0.5rem; }
.col-12 { width: 100%; }

@media (min-width: 768px) {
    .md\:col-4 { width: 33.3333%; }
    .md\:col-6 { width: 50%; }
    .md\:col-8 { width: 66.6666%; }
}

@media (min-width: 992px) {
    .lg\:col-4 { width: 33.3333%; }
    .lg\:col-5 { width: 41.6666%; }
    .lg\:col-6 { width: 50%; }
    .lg\:col-7 { width: 58.3333%; }
    .lg\:col-8 { width: 66.6666%; }
    .lg\:col-12 { width: 100%; }
}

.grid > [class*="col-"] > .p-card,
.grid > [class*="col-"] > .chart-card,
.grid > [class*="col-"] > .stat-card { height: 100%; }

/* ===== TABS (Bootstrap nav-tabs customizado) ===== */
.nav-tabs { border-bottom: 2px solid var(--border); gap: 0; }
.nav-tabs .nav-link {
    color: var(--text-secondary);
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.2s, border-color 0.2s;
    border-radius: 0;
}
.nav-tabs .nav-link:hover { color: var(--primary); border-color: transparent; background: none; }
.nav-tabs .nav-link.active { color: var(--primary); border-bottom-color: var(--primary); background: none; }

/* ===== UPLOAD PREVIEW ===== */
.upload-preview { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; border: 3px solid var(--border); display: block; margin-bottom: 0.75rem; }
.upload-preview-square { width: 120px; height: 120px; border-radius: 12px; object-fit: cover; border: 2px solid var(--border); display: block; margin-bottom: 0.75rem; }

/* ===== UTILITÁRIOS ===== */
.text-muted { color: var(--text-secondary) !important; font-size: 0.82rem; }

/* Busca no header do card */
.dt-header-search {
    display: flex;
    align-items: center;
    gap: .4rem;
    background: var(--content-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .3rem .75rem;
    transition: border-color .2s;
}
.dt-header-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.dt-header-search input { color: var(--text-primary) !important; }
[data-dark="1"] .dt-header-search { background: var(--card-bg); border-color: var(--border); }
[data-dark="1"] .dt-header-search input { color: var(--text-primary) !important; }

/* ===== RESPONSIVIDADE MOBILE ===== */

/* Botão hamburguer — oculto no desktop */
.sidebar-toggle {
    display: none;
    width: 36px; height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.12);
    background: none;
    color: rgba(255,255,255,0.7);
    align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1.1rem;
    flex-shrink: 0;
    margin-right: 0.25rem;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.08); }

/* Overlay — oculto por padrão */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 299;
}
.sidebar-overlay.open { display: block; }

@media (max-width: 768px) {

    /* Sidebar vira drawer */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        z-index: 300;
    }
    .sidebar.open {
        transform: translateX(0);
    }

    /* Conteúdo ocupa tela toda */
    .admin-main {
        margin-left: 0 !important;
    }

    /* Mostra hamburguer */
    .sidebar-toggle {
        display: flex;
    }

    /* Topbar compacta */
    .topbar {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }
    .topbar-breadcrumb {
        display: none;
    }
    .topbar-title {
        font-size: 0.88rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .topbar-user-info,
    .topbar-chevron {
        display: none;
    }
    .topbar-user-btn {
        padding: 0.25rem;
        border: none;
        background: none;
    }

    /* Conteúdo */
    .page-content {
        padding: 0.875rem;
    }

    /* Card header empilha */
    .p-card-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    .p-card-header .ms-auto {
        margin-left: 0 !important;
        width: 100%;
    }
    .p-card-header .d-flex {
        flex-wrap: wrap;
        width: 100%;
        gap: 0.5rem;
    }

    /* Paginação empilha */
    .p-card-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    /* Tabela scroll horizontal */
    .dt-wrapper {
        padding: 0.5rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Stat cards */
    .stat-value { font-size: 1.35rem; }
    .stat-card { padding: 1rem; }

    /* Grid cols viram 100% */
    .md\:col-4, .md\:col-6, .md\:col-8,
    .lg\:col-4, .lg\:col-5, .lg\:col-6,
    .lg\:col-7, .lg\:col-8 {
        width: 100% !important;
    }
}

/* ===== PRINT ===== */
@media print {
    .sidebar, .topbar, .no-print, .dt-top, .dt-bottom { display: none !important; }
    .admin-main { margin-left: 0; }
    .page-content { padding: 0; }
    .p-card { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
    .chart-card { break-inside: avoid; }
    canvas { max-width: 100% !important; max-height: 180px !important; }
    .row { display: flex !important; flex-wrap: wrap !important; }
    .col-12, [class*="col-lg-"], [class*="col-md-"] { width: 100% !important; }
    .col-lg-5, .col-lg-7, .lg\:col-5, .lg\:col-7 { width: 50% !important; }
}
