/* ============================================================
   HoleritePG — Stylesheet Principal
   ============================================================ */

:root {
  --primary:        #1a56db;
  --primary-dark:   #1e429f;
  --secondary:      #6b7280;
  --success:        #057a55;
  --danger:         #c81e1e;
  --warning:        #b45309;
  --info:           #0e9f6e;
  --sidebar-bg:     #111827;
  --sidebar-hover:  #1f2937;
  --sidebar-active: #1a56db;
  --sidebar-text:   #d1d5db;
  --sidebar-muted:  #6b7280;
  --sidebar-width:  260px;
  --topbar-h:       60px;
  --body-bg:        #f3f4f6;
  --card-bg:        #ffffff;
  --border-color:   #e5e7eb;
  --text-main:      #111827;
  --text-muted:     #6b7280;
  --radius:         10px;
}

/* ---- Reset & Base ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text-main);
  font-size: 14px;
}

/* ---- Sidebar --------------------------------------------- */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-width); height: 100vh;
  background: var(--sidebar-bg);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  z-index: 1000;
  transition: width .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: var(--topbar-h);
  border-bottom: 1px solid #1f2937;
  text-decoration: none;
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--primary); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-brand .brand-icon svg { width: 20px; height: 20px; fill: #fff; }
.sidebar-brand .brand-text { font-size: 16px; font-weight: 700; color: #fff; white-space: nowrap; }
.sidebar-brand .brand-sub { font-size: 10px; color: var(--sidebar-muted); display: block; line-height: 1; }

.sidebar-empresa {
  margin: 12px; padding: 10px 12px;
  background: #1f2937; border-radius: 8px;
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  transition: background .2s;
}
.sidebar-empresa:hover { background: #374151; }
.sidebar-empresa .emp-icon {
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--primary-dark); display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.sidebar-empresa .emp-name { color: #fff; font-size: 12px; font-weight: 600; line-height: 1.3; }
.sidebar-empresa .emp-cnpj { color: var(--sidebar-muted); font-size: 10px; }

.sidebar-section { padding: 16px 16px 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--sidebar-muted); }

.sidebar-nav { list-style: none; margin: 0; padding: 0 8px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 7px; text-decoration: none;
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s; margin-bottom: 2px;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .7; transition: opacity .15s; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a:hover svg { opacity: 1; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-nav .badge-menu {
  margin-left: auto; background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto; border-top: 1px solid #1f2937;
  padding: 12px 8px;
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 7px; text-decoration: none; color: var(--sidebar-text);
  transition: background .15s;
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-user .user-av {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user .user-name { font-size: 12px; font-weight: 600; color: #fff; }
.sidebar-user .user-role { font-size: 10px; color: var(--sidebar-muted); }

/* ---- Topbar ---------------------------------------------- */
.topbar {
  position: fixed; top: 0; left: var(--sidebar-width); right: 0;
  height: var(--topbar-h); background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; padding: 0 24px;
  z-index: 900; gap: 16px;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--text-main); }
.topbar-breadcrumb { font-size: 12px; color: var(--text-muted); }
.topbar-search {
  flex: 1; max-width: 320px; margin-left: auto;
  position: relative;
}
.topbar-search input {
  width: 100%; padding: 7px 12px 7px 36px;
  border: 1px solid var(--border-color); border-radius: 8px;
  font-size: 13px; background: var(--body-bg); outline: none;
  transition: border-color .2s;
}
.topbar-search input:focus { border-color: var(--primary); }
.topbar-search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.topbar-btn {
  width: 36px; height: 36px; border-radius: 8px; border: none; cursor: pointer;
  background: var(--body-bg); display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); transition: background .15s, color .15s;
}
.topbar-btn:hover { background: var(--border-color); color: var(--text-main); }
.topbar-btn svg { width: 18px; height: 18px; }
.topbar-competencia {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 8px; border: 1px solid var(--border-color);
  font-size: 12px; font-weight: 600; color: var(--text-main); background: var(--body-bg);
  cursor: pointer;
}

/* ---- Main Content ---------------------------------------- */
.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-h);
  min-height: 100vh;
}
.page-inner { padding: 24px; }

/* ---- Page Header ----------------------------------------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-header .page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ---- Cards ----------------------------------------------- */
.card {
  background: var(--card-bg); border-radius: var(--radius);
  border: 1px solid var(--border-color); overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-header h5 { font-size: 14px; font-weight: 700; margin: 0; }
.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border-color); background: #fafafa; }

/* ---- Stat Cards ------------------------------------------ */
.stat-card {
  background: var(--card-bg); border-radius: var(--radius);
  border: 1px solid var(--border-color); padding: 20px;
  display: flex; align-items: flex-start; gap: 16px;
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,.08); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue   { background: #eff6ff; color: var(--primary); }
.stat-icon.green  { background: #f0fdf4; color: #16a34a; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.purple { background: #faf5ff; color: #9333ea; }
.stat-icon.red    { background: #fef2f2; color: #dc2626; }
.stat-icon.teal   { background: #f0fdfa; color: #0d9488; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text-main); line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-change { font-size: 11px; font-weight: 600; margin-top: 6px; }
.stat-change.up   { color: #16a34a; }
.stat-change.down { color: #dc2626; }

/* ---- Tables ---------------------------------------------- */
.table-responsive { overflow-x: auto; }
table.hp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.hp-table thead th {
  padding: 11px 14px; text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); border-bottom: 2px solid var(--border-color);
  white-space: nowrap; background: #fafafa;
}
table.hp-table tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
table.hp-table tbody tr:last-child td { border-bottom: none; }
table.hp-table tbody tr:hover { background: #fafafa; }
table.hp-table tfoot td { padding: 11px 14px; font-weight: 700; border-top: 2px solid var(--border-color); }

/* ---- Forms ----------------------------------------------- */
.form-label { font-size: 12px; font-weight: 600; color: var(--text-main); margin-bottom: 5px; display: block; }
.form-control, .form-select {
  width: 100%; padding: 8px 12px; font-size: 13px;
  border: 1px solid var(--border-color); border-radius: 7px; outline: none;
  background: #fff; color: var(--text-main); transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
.form-control.is-invalid { border-color: #dc2626; }
.invalid-feedback { font-size: 11px; color: #dc2626; margin-top: 4px; }
.form-text { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: 7px 0 0 7px; }
.input-group .input-group-text {
  padding: 8px 12px; border: 1px solid var(--border-color); border-left: none;
  border-radius: 0 7px 7px 0; background: #f9fafb; font-size: 13px; color: var(--text-muted);
}

/* ---- Buttons --------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 7px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none; transition: all .15s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success   { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger    { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning   { background: #d97706; color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-secondary { background: #e5e7eb; color: var(--text-main); }
.btn-secondary:hover { background: #d1d5db; }
.btn-outline   { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: var(--body-bg); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--body-bg); color: var(--text-main); }
.btn-icon      { width: 32px; height: 32px; padding: 0; justify-content: center; }
.btn-icon svg  { width: 16px; height: 16px; }

/* ---- Badges ---------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.badge-success  { background: #dcfce7; color: #166534; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: #e0f2fe; color: #075985; }
.badge-secondary{ background: #f3f4f6; color: #374151; }
.badge-primary  { background: #eff6ff; color: var(--primary-dark); }

/* ---- Alerts ---------------------------------------------- */
.alert {
  padding: 12px 16px; border-radius: 8px; font-size: 13px;
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert-danger   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-warning  { background: #fffbeb; border: 1px solid #fed7aa; color: #92400e; }
.alert-info     { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ---- 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); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }

/* ---- Misc ------------------------------------------------ */
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.fw-bold     { font-weight: 700; }
.fw-semi     { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.divider { border: none; border-top: 1px solid var(--border-color); margin: 16px 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
  background: var(--primary);
}
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
  background: var(--body-bg); border: 1px solid var(--border-color); color: var(--text-muted);
}

/* ---- Modal ----------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000; padding: 20px;
}
.modal-box {
  background: #fff; border-radius: 12px; width: 100%; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-box.sm  { max-width: 420px; }
.modal-box.md  { max-width: 640px; }
.modal-box.lg  { max-width: 900px; }
.modal-box.xl  { max-width: 1100px; }
.modal-header  { padding: 18px 24px; border-bottom: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between; }
.modal-header h4 { font-size: 15px; font-weight: 700; margin: 0; }
.modal-body    { padding: 24px; }
.modal-footer  { padding: 14px 24px; border-top: 1px solid var(--border-color);
  display: flex; gap: 8px; justify-content: flex-end; }

/* ---- Tabs ------------------------------------------------ */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border-color); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; background: none; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ---- Holerite Print -------------------------------------- */
@media print {
  .sidebar, .topbar, .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0 !important; padding-top: 0 !important; }
  .holerite-print { page-break-after: always; }
}

/* ---- Login ----------------------------------------------- */
.login-wrapper {
  min-height: 100vh; display: flex;
  background: linear-gradient(135deg, #1a56db 0%, #1e429f 100%);
}
.login-left {
  flex: 1; display: flex; flex-direction: column;
  justify-content: center; align-items: center; padding: 40px;
  color: #fff; text-align: center;
}
.login-left h1 { font-size: 36px; font-weight: 800; margin: 0; }
.login-left p  { font-size: 16px; opacity: .8; margin-top: 8px; }
.login-right {
  width: 440px; background: #fff; display: flex; flex-direction: column;
  justify-content: center; padding: 48px 40px;
}
.login-right h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-right p  { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

/* ---- Responsive ------------------------------------------ */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2,1fr); }
  .grid-6 { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .login-left { display: none; }
  .login-right { width: 100%; }
  .page-inner { padding: 16px; }
}

/* ---- Scrollbar ------------------------------------------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ---- Holerite Document ----------------------------------- */
.holerite-doc {
  background: #fff; font-family: 'Courier New', monospace;
  font-size: 12px; padding: 24px; max-width: 780px; margin: 0 auto;
  border: 1px solid var(--border-color); border-radius: 8px;
}
.holerite-doc h2 { font-size: 14px; text-align: center; margin: 0 0 4px; }
.holerite-doc .hl-empresa { text-align: center; font-size: 11px; color: var(--text-muted); }
.holerite-doc table { width: 100%; font-size: 11px; }
.holerite-doc .hl-header { background: #f3f4f6; padding: 8px; border-radius: 4px; margin: 12px 0; }
.holerite-doc .hl-linha { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #e5e7eb; }
.holerite-doc .hl-total { font-weight: 700; border-top: 2px solid #111; margin-top: 4px; }
.holerite-doc .hl-assinaturas { display: flex; gap: 40px; margin-top: 30px; }
.holerite-doc .hl-assinatura { flex: 1; border-top: 1px solid #111; padding-top: 6px; text-align: center; font-size: 10px; }

/* ---- Tooltips -------------------------------------------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; font-size: 11px; padding: 4px 8px; border-radius: 5px;
  white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .2s;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ---- Loading Spinner ------------------------------------- */
.spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #e5e7eb; border-top-color: var(--primary);
  animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
