/* ═══════════════════════════════════════════════════════
   ClickPortugal Admin — Design System v3
   Dark / Light mode + tamanhos aumentados
═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');

/* ══════════════════════════════════════════════════════
   MODO CLARO (default)
══════════════════════════════════════════════════════ */
:root {
    --brand:           #2563eb;
    --brand-light:     #3b82f6;
    --brand-soft:      #eff6ff;
    --brand-border:    #bfdbfe;

    --sidebar-bg:      #0f172a;
    --sidebar-sub:     #080e1c;
    --sidebar-hover:   #1e293b;
    --sidebar-text:    #94a3b8;
    --sidebar-active:  #e2e8f0;
    --sidebar-w:       270px;

    --surface:         #ffffff;
    --surface-2:       #f8fafc;
    --surface-3:       #f1f5f9;
    --surface-4:       #e2e8f0;

    --border:          #e2e8f0;
    --border-soft:     #f1f5f9;

    --text:            #0f172a;
    --text-2:          #475569;
    --text-3:          #94a3b8;

    --success:         #10b981;
    --success-soft:    #ecfdf5;
    --success-border:  #a7f3d0;
    --warning:         #f59e0b;
    --warning-soft:    #fffbeb;
    --warning-border:  #fde68a;
    --danger:          #ef4444;
    --danger-soft:     #fef2f2;
    --danger-border:   #fecaca;

    --radius:          10px;
    --radius-sm:       6px;
    --shadow:          0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:       0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg:       0 10px 30px rgba(0,0,0,.12);
    --transition:      .18s cubic-bezier(.4,0,.2,1);
}

/* ══════════════════════════════════════════════════════
   MODO ESCURO
══════════════════════════════════════════════════════ */
[data-theme="dark"] {
    --brand:           #3b82f6;
    --brand-light:     #60a5fa;
    --brand-soft:      rgba(59,130,246,.12);
    --brand-border:    rgba(59,130,246,.3);

    --sidebar-bg:      #0a0f1a;
    --sidebar-sub:     #050810;
    --sidebar-hover:   #111827;
    --sidebar-text:    #64748b;
    --sidebar-active:  #f1f5f9;

    --surface:         #111827;
    --surface-2:       #0f172a;
    --surface-3:       #1e293b;
    --surface-4:       #2d3748;

    --border:          #1e293b;
    --border-soft:     #161f2e;

    --text:            #f1f5f9;
    --text-2:          #94a3b8;
    --text-3:          #475569;

    --success-soft:    rgba(16,185,129,.12);
    --success-border:  rgba(16,185,129,.25);
    --warning-soft:    rgba(245,158,11,.12);
    --warning-border:  rgba(245,158,11,.25);
    --danger-soft:     rgba(239,68,68,.12);
    --danger-border:   rgba(239,68,68,.25);

    --shadow:          0 1px 3px rgba(0,0,0,.3), 0 1px 2px rgba(0,0,0,.2);
    --shadow-md:       0 4px 12px rgba(0,0,0,.4);
    --shadow-lg:       0 10px 30px rgba(0,0,0,.5);
}

/* ══════════════════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--surface-2);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

/* ══════════════════════════════════════════════════════
   LAYOUT
══════════════════════════════════════════════════════ */
.admin-body  { background: var(--surface-2); }

.admin-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    padding: 30px 36px;
    margin-left: var(--sidebar-w);
    max-width: calc(100vw - var(--sidebar-w));
    min-height: 100vh;
}

/* ══════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    z-index: 100;
    scrollbar-width: thin;
    scrollbar-color: #1e293b transparent;
    transition: background var(--transition);
}

/* Logo */
.logo {
    padding: 26px 22px 22px;
    border-bottom: 1px solid rgba(255,255,255,.06);
    flex-shrink: 0;
}

.logo h2 {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: -.4px;
    line-height: 1.2;
}

.logo p {
    font-size: 11.5px;
    color: #475569;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-top: 4px;
}

/* Nav */
.sidebar-nav { padding: 14px 0; flex: 1; }
.sidebar-nav ul { list-style: none; }

.nav-item > a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 22px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 500;
    transition: color var(--transition), background var(--transition);
    position: relative;
    white-space: nowrap;
}

.nav-item > a:hover {
    color: var(--sidebar-active);
    background: var(--sidebar-hover);
}

.nav-item.active > a {
    color: #fff;
    background: var(--sidebar-hover);
}

.nav-item.active > a::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--brand-light);
    border-radius: 0 2px 2px 0;
}

/* Ícone nav */
.nav-icon {
    font-size: 16px;
    width: 22px;
    text-align: center;
    flex-shrink: 0;
}

/* Submenu arrow */
.has-submenu > a { justify-content: space-between; }

.has-submenu > a .nav-arrow {
    font-size: 14px;
    color: #475569;
    transition: transform var(--transition), color var(--transition);
    margin-left: auto;
    flex-shrink: 0;
    line-height: 1;
}

.has-submenu.open > a .nav-arrow {
    transform: rotate(90deg);
    color: var(--brand-light);
}

.submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s cubic-bezier(.4,0,.2,1);
    background: var(--sidebar-sub);
}

.has-submenu.open .submenu { max-height: 400px; }

.submenu li a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 22px 9px 42px;
    color: #64748b;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 400;
    transition: color var(--transition), background var(--transition);
}

.submenu li a:hover {
    color: #cbd5e1;
    background: var(--sidebar-hover);
}

.submenu li.active a { color: var(--brand-light); }

/* Logout */
.nav-item .logout-btn {
    color: #64748b !important;
    margin-top: 4px;
    border-top: 1px solid rgba(255,255,255,.05);
}

.nav-item .logout-btn:hover {
    color: var(--danger) !important;
    background: rgba(239,68,68,.08) !important;
}

/* ══════════════════════════════════════════════════════
   TOGGLE DARK / LIGHT  (botão no topo da sidebar)
══════════════════════════════════════════════════════ */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 22px;
    border-top: 1px solid rgba(255,255,255,.05);
    margin-top: auto;
    flex-shrink: 0;
}

.theme-toggle span {
    font-size: 12px;
    color: #475569;
    font-weight: 500;
    letter-spacing: .04em;
}

.toggle-btn {
    position: relative;
    width: 44px;
    height: 24px;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 12px;
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
}

.toggle-btn::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 16px; height: 16px;
    background: #64748b;
    border-radius: 50%;
    transition: transform var(--transition), background var(--transition);
}

[data-theme="dark"] .toggle-btn {
    background: var(--brand);
    border-color: var(--brand-light);
}

[data-theme="dark"] .toggle-btn::after {
    transform: translateX(20px);
    background: #fff;
}

.toggle-icon {
    font-size: 15px;
    line-height: 1;
}

/* ══════════════════════════════════════════════════════
   HEADER DA PÁGINA
══════════════════════════════════════════════════════ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 26px;
    gap: 16px;
    flex-wrap: wrap;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.5px;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* ══════════════════════════════════════════════════════
   BOTÕES
══════════════════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 1px 2px rgba(37,99,235,.3);
}
.btn-primary:hover {
    background: var(--brand-light);
    box-shadow: 0 4px 12px rgba(37,99,235,.4);
    transform: translateY(-1px);
    color: #fff;
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-2);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--surface-3);
    border-color: var(--surface-4);
}

.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #dc2626; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }

.btn-sm { padding: 7px 13px; font-size: 13px; }

/* Ação inline nas tabelas */
a.btn-sm.btn-edit,
button.btn-sm.btn-delete {
    padding: 5px 11px;
    font-size: 13px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition);
}

a.btn-sm.btn-edit {
    background: var(--brand-soft);
    color: var(--brand);
    border: 1px solid var(--brand-border);
}
a.btn-sm.btn-edit:hover { background: #dbeafe; }

button.btn-sm.btn-delete {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}
button.btn-sm.btn-delete:hover { background: #fee2e2; }

/* ══════════════════════════════════════════════════════
   CARDS DE ESTATÍSTICAS
══════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 18px;
    margin: 0 0 30px;
}

.stat-card {
    background: var(--surface);
    padding: 22px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: box-shadow var(--transition), transform var(--transition);
    cursor: default;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 30px;
    width: 56px; height: 56px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-3);
    border-radius: 12px;
    flex-shrink: 0;
}

.stat-info { flex: 1; min-width: 0; }

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    font-family: 'DM Mono', monospace;
    letter-spacing: -1px;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-3);
    font-weight: 500;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ══════════════════════════════════════════════════════
   TABELAS
══════════════════════════════════════════════════════ */
.content-section {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 26px;
    transition: background var(--transition), border-color var(--transition);
}

.content-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    padding: 20px 22px 18px;
    border-bottom: 1px solid var(--border);
}

.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
}

.data-table th {
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text);
    font-size: 14px;
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition); }
.data-table tbody tr:hover { background: var(--surface-2); }

/* ══════════════════════════════════════════════════════
   BADGES / STATUS
══════════════════════════════════════════════════════ */
.status, .badge {
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    text-transform: capitalize;
}

.status.sim, .status.approved, .badge-success {
    background: var(--success-soft);
    color: #065f46;
    border: 1px solid var(--success-border);
}
.status.nao, .status.pending, .badge-warning {
    background: var(--warning-soft);
    color: #92400e;
    border: 1px solid var(--warning-border);
}
.status.nao_aprovado, .status.rejected, .badge-danger {
    background: var(--danger-soft);
    color: #991b1b;
    border: 1px solid var(--danger-border);
}
.badge-info {
    background: var(--brand-soft);
    color: #1e40af;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
    border: 1px solid var(--brand-border);
}

/* ══════════════════════════════════════════════════════
   FILTROS / PESQUISA
══════════════════════════════════════════════════════ */
.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.search-box, .filter-select {
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.search-box {
    min-width: 220px;
    flex: 1;
    max-width: 320px;
}

.search-box:focus, .filter-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

/* ══════════════════════════════════════════════════════
   FORMULÁRIOS
══════════════════════════════════════════════════════ */
.form-compact { padding: 22px; }

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    margin-bottom: 7px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-2);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.form-group input::placeholder { color: var(--text-3); }

.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 8px;
    flex-wrap: wrap;
}

/* Checkboxes */
.cats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
    gap: 8px;
    background: var(--surface-3);
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.cat-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    background: var(--surface);
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid var(--border);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-2);
    transition: all var(--transition);
}

.cat-check:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-soft);
}

.cat-check input { accent-color: var(--brand); }

.btn-xs {
    padding: 5px 11px;
    background: var(--surface-3);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12.5px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-2);
    margin-right: 5px;
    transition: background var(--transition);
}
.btn-xs:hover { background: var(--surface-4); }

/* ══════════════════════════════════════════════════════
   ALERTAS
══════════════════════════════════════════════════════ */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid transparent;
    transition: opacity .3s ease;
}

.alert-success {
    background: var(--success-soft);
    color: #065f46;
    border-color: var(--success-border);
}
.alert-error {
    background: var(--danger-soft);
    color: #991b1b;
    border-color: var(--danger-border);
}
.alert-warning {
    background: var(--warning-soft);
    color: #92400e;
    border-color: var(--warning-border);
}

/* ══════════════════════════════════════════════════════
   LOGIN
══════════════════════════════════════════════════════ */
.login-body {
    background: var(--sidebar-bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    background: var(--surface);
    padding: 48px 44px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}
.login-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.5px;
}
.login-header p { font-size: 14px; color: var(--text-3); margin-top: 6px; }

.btn-block { width: 100%; justify-content: center; padding: 12px 18px; font-size: 15px; }

/* ══════════════════════════════════════════════════════
   FOOTER
══════════════════════════════════════════════════════ */
.admin-footer {
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 16px 36px;
    margin-left: var(--sidebar-w);
    transition: background var(--transition);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12.5px;
    color: var(--text-3);
}

.footer-section a {
    color: var(--text-3);
    text-decoration: none;
    transition: color var(--transition);
}
.footer-section a:hover { color: var(--brand); }

/* ══════════════════════════════════════════════════════
   BADGE CAT
══════════════════════════════════════════════════════ */
.badge-cat {
    background: var(--brand-soft);
    color: #1e40af;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin: 2px;
    display: inline-block;
    border: 1px solid var(--brand-border);
}

/* ══════════════════════════════════════════════════════
   SCROLL FINO
══════════════════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--surface-4); }

/* ══════════════════════════════════════════════════════
   TEXTO MUTED / MISC
══════════════════════════════════════════════════════ */
.text-muted { color: var(--text-3); font-style: italic; font-size: 13.5px; }

/* ══════════════════════════════════════════════════════
   RESPONSIVO
══════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; padding: 16px; max-width: 100vw; }
    .admin-footer { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
    .form-row { flex-direction: column; }
    .stats-grid { grid-template-columns: 1fr; }
    .footer-content { flex-direction: column; text-align: center; }
    .header { flex-direction: column; align-items: flex-start; }
}
