/* ══════════════════════════════════════════════
   fiscoRD — Modern SaaS Layout
   Sidebar + Top Header design
   ══════════════════════════════════════════════ */

:root {
  --sidebar-width: 250px;
  --sidebar-collapsed: 62px;
  --topbar-height: 56px;
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --accent-green: #22c55e;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
  background: var(--body-bg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  margin: 0;
  min-height: 100vh;
}

/* ── SIDEBAR ───────────────────────────────── */
.fisco-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, transform 0.3s ease;
  overflow-x: hidden;
  box-shadow: 2px 0 8px rgba(0,0,0,0.15);
}

.fisco-sidebar.collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  min-height: var(--topbar-height);
  gap: 10px;
  text-decoration: none;
}

.sidebar-brand .brand-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--primary), #4f9cf7);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  color: white;
  font-weight: 800;
}

.sidebar-brand .brand-text {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  letter-spacing: -0.3px;
}

.sidebar-brand .brand-text span {
  color: var(--primary);
  font-weight: 800;
}

.fisco-sidebar.collapsed .brand-text,
.fisco-sidebar.collapsed .nav-label,
.fisco-sidebar.collapsed .section-title,
.fisco-sidebar.collapsed .nav-arrow,
.fisco-sidebar.collapsed .sidebar-empresa {
  display: none;
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-section {
  margin-bottom: 4px;
}

.section-title {
  padding: 12px 20px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(148,163,184,0.5);
  white-space: nowrap;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 9px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  gap: 12px;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  border-left-color: rgba(255,255,255,0.15);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-left-color: var(--primary);
}

.sidebar-link i {
  font-size: 17px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link:hover i,
.sidebar-link.active i {
  opacity: 1;
}

.nav-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
}

.nav-arrow {
  font-size: 11px;
  transition: transform 0.2s;
  opacity: 0.4;
}

/* Sub-menu */
.sidebar-submenu {
  display: none;
  padding: 2px 0;
  background: rgba(0,0,0,0.15);
}

.sidebar-submenu.show {
  display: block;
}

.sidebar-submenu .sidebar-link {
  padding: 7px 16px 7px 50px;
  font-size: 13px;
  font-weight: 400;
  border-left: 3px solid transparent;
}

.sidebar-submenu .sidebar-link:hover {
  border-left-color: rgba(255,255,255,0.08);
}

/* Sidebar Footer / Empresa */
.sidebar-empresa {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  white-space: nowrap;
}

.sidebar-empresa .emp-name {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 500;
}

.sidebar-empresa .emp-env {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
  margin-top: 4px;
}

.sidebar-empresa .emp-env.prod { background: #22c55e22; color: #22c55e; }
.sidebar-empresa .emp-env.cert { background: #f59e0b22; color: #f59e0b; }

/* Sidebar Collapse Button */
.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: rgba(255,255,255,0.04);
  border-top: 1px solid rgba(255,255,255,0.08);
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.sidebar-collapse-btn:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-collapse-btn i {
  font-size: 16px;
  transition: transform 0.3s ease;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.fisco-sidebar.collapsed .sidebar-collapse-btn .nav-label {
  display: none;
}

.fisco-sidebar.collapsed .sidebar-collapse-btn i {
  transform: rotate(180deg);
}

/* ── TOPBAR ────────────────────────────────── */
.fisco-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  z-index: 1030;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  transition: left 0.3s ease;
  box-shadow: var(--shadow-sm);
}

.fisco-sidebar.collapsed ~ .fisco-topbar {
  left: var(--sidebar-collapsed);
}

.topbar-toggle {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.topbar-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.topbar-breadcrumb {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
}

.topbar-user:hover {
  background: #f8fafc;
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #4f9cf7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
}

/* ── MAIN CONTENT ──────────────────────────── */
.fisco-main {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  padding: 24px 28px;
  min-height: calc(100vh - var(--topbar-height));
  transition: margin-left 0.3s ease;
}

.fisco-sidebar.collapsed ~ .fisco-main {
  margin-left: var(--sidebar-collapsed);
}

/*
 * Neutralize ALL container wrappers inside fisco-main.
 * Many child templates wrap content in Bootstrap containers (.container-fluid,
 * .container, .container-lg) with .py-4 which adds extra padding.
 * fisco-main already handles padding, so we strip it from child containers.
 */
.fisco-main > .container-fluid,
.fisco-main > .container-lg,
.fisco-main > .container-md,
.fisco-main > .container,
.fisco-main > .container-sm,
.fisco-main > .container-xl,
.fisco-main > .container-xxl {
  padding-left: 0 !important;
  padding-right: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
}

/* Remove py-4 double padding on direct child elements */
.fisco-main > .py-4 {
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* ── CARDS ─────────────────────────────────── */
.card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm) !important;  /* Override Bootstrap shadow-sm */
  background: var(--card-bg);
  transition: box-shadow 0.2s ease;
}

/* Only hover on clickable cards, not all cards */
a.card:hover,
.card-hover:hover {
  box-shadow: var(--shadow-md) !important;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  padding: 16px 20px;
  font-size: 14px;
}

.card-body {
  padding: 20px;
}

/* ── KPI CARDS (Dashboard) ─────────────────── */
.kpi-card {
  border: none;
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md) !important;
}

.kpi-card .kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 12px;
}

.kpi-card .kpi-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-card .kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.kpi-blue   { background: linear-gradient(135deg, #eff6ff, #dbeafe); }
.kpi-blue .kpi-icon  { background: #1a73e822; color: var(--primary); }
.kpi-green  { background: linear-gradient(135deg, #f0fdf4, #dcfce7); }
.kpi-green .kpi-icon { background: #22c55e22; color: var(--accent-green); }
.kpi-orange { background: linear-gradient(135deg, #fffbeb, #fef3c7); }
.kpi-orange .kpi-icon { background: #f59e0b22; color: var(--accent-orange); }
.kpi-red    { background: linear-gradient(135deg, #fef2f2, #fecaca); }
.kpi-red .kpi-icon { background: #ef444422; color: var(--accent-red); }

/* ── PAGE HEADERS (normalize h1-h5 inside content) ── */
.fisco-main h1, .fisco-main h2, .fisco-main h3 {
  font-weight: 700;
  color: var(--text-primary);
}

/* Normalize large headers used as page titles inside content */
.fisco-main > .container-fluid > h1,
.fisco-main > .container-fluid > .row > div > h1,
.fisco-main > h1 {
  font-size: 1.35rem;
  margin-bottom: 1rem;
}

.fisco-main h1.h2 { font-size: 1.35rem; }
.fisco-main h1.h3 { font-size: 1.25rem; }

/* h4 used as page titles in non-container templates */
.fisco-main h4 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.fisco-main h5 {
  font-size: 1rem;
  font-weight: 600;
}

/* ── TABLES ────────────────────────────────── */
.table {
  font-size: 13.5px;
}

.table thead th {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
  padding: 12px 16px;
  background: transparent !important;  /* Override table-light */
}

/* Override Bootstrap table-light to use our clean style */
.table .table-light th,
.table-light th,
thead.table-light th {
  background: #f8fafc !important;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody td {
  padding: 12px 16px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

.table-hover tbody tr:hover {
  background: #f8fafc;
}

/* ── BADGES ────────────────────────────────── */
.badge {
  font-weight: 500;
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 6px;
}

/* ── BUTTONS ───────────────────────────────── */
.btn {
  font-weight: 500;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  padding: 8px 16px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

/* ── FORMS ─────────────────────────────────── */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--border-color);
  font-size: 13.5px;
  padding: 8px 12px;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}

.form-label {
  font-weight: 500;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ── ALERTS ────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: none;
}

/* ── PAGE HEADER UTILITY ─────────────────── */
.page-header {
  margin-bottom: 24px;
}

.page-header h4, .page-header h5 {
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* ── DROPDOWN MENUS ──────────────────────── */
.dropdown-menu {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 13.5px;
}

.dropdown-item {
  padding: 8px 16px;
  font-size: 13.5px;
}

.dropdown-item:hover {
  background: var(--primary-light);
}

/* ── MODALS ───────────────────────────────── */
.modal-content {
  border-radius: var(--radius);
  border: none;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
}

.modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 12px 20px;
}

/* ── PAGINATION ──────────────────────────── */
.pagination .page-link {
  border-radius: var(--radius-sm);
  margin: 0 2px;
  font-size: 13px;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}

/* ── RESPONSIVE ────────────────────────────── */
@media (max-width: 991px) {
  .fisco-sidebar {
    transform: translateX(-100%);
  }
  .fisco-sidebar.mobile-open {
    transform: translateX(0);
  }
  .fisco-topbar {
    left: 0 !important;
  }
  .fisco-main {
    margin-left: 0 !important;
    padding: 16px;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1035;
  }
  .sidebar-overlay.show {
    display: block;
  }
}

@media (max-width: 575px) {
  .fisco-main {
    padding: 12px;
  }
  .card-body {
    padding: 16px;
  }
  .card-header {
    padding: 12px 16px;
  }
}

/* ── SCROLLBAR ─────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── LINKS ─────────────────────────────────── */
a {
  color: var(--primary);
}
a:hover {
  color: var(--primary-dark);
}

/* ── UTILITIES ─────────────────────────────── */
.text-muted { color: var(--text-secondary) !important; }
.fw-600 { font-weight: 600; }

/* ── BLOCKED USER STATE ───────────────────── */
.blocked-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  flex-direction: column;
}

.blocked-topbar {
  background: #0f172a;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.blocked-topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.blocked-topbar-brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.9rem;
}

.blocked-topbar-brand-text {
  color: #e2e8f0;
  font-weight: 700;
  font-size: 1.1rem;
}

.blocked-topbar-brand-text span {
  color: #3b82f6;
}

.blocked-topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.blocked-topbar-avatar {
  width: 32px;
  height: 32px;
  background: #334155;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-weight: 600;
  font-size: 0.8rem;
}

.blocked-topbar-username {
  color: #94a3b8;
  font-size: 0.85rem;
}

.blocked-topbar-logout {
  font-size: 0.78rem;
}

.blocked-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.blocked-card {
  background: white;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.3);
  max-width: 520px;
  width: 100%;
  overflow: hidden;
}

.blocked-card-header {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  padding: 2.5rem 2rem 1.5rem;
  text-align: center;
}

.blocked-card-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(245,158,11,0.15);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.blocked-card-icon i {
  font-size: 2rem;
  color: #d97706;
}

.blocked-card-body {
  padding: 2rem;
  text-align: center;
}

.blocked-card-body h4 {
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.5rem;
}

.blocked-card-empresa {
  color: #64748b;
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.blocked-card-badge {
  padding: 0.35rem 1rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: inline-block;
}

.blocked-card-detail {
  color: #64748b;
  font-size: 0.88rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.blocked-card-info {
  background: #f1f5f9;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  color: #475569;
  margin-bottom: 1.5rem;
}

.blocked-card-info i {
  color: #3b82f6;
}

.blocked-card-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ── LOGIN PAGE ───────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

/* ── SUPERUSER SIDEBAR HIGHLIGHT ─────────── */
.sidebar-superuser-text {
  color: #f59e0b;
}

.sidebar-superuser-icon {
  color: #f59e0b;
}

/* ── CHEVRON DROPDOWN SMALL ──────────────── */
.topbar-chevron-down {
  font-size: 11px;
  opacity: 0.5;
}

/* ── COMMON INLINE STYLE REPLACEMENTS ────── */
.status-dot {
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  font-size: 0.85rem;
}

.dropdown-autocomplete {
  z-index: 1050;
  max-height: 250px;
  overflow-y: auto;
  display: none;
}

.search-box-sm {
  max-width: 600px;
}

.date-filter-sm {
  max-width: 160px;
}

.inline-field-xs {
  width: 65px;
  display: inline-block;
}

.inline-field-sm {
  width: 70px;
  display: inline-block;
}

.inline-field-md {
  width: 90px;
  display: inline-block;
}

.inline-field-lg {
  width: 95px;
  display: inline-block;
}
