/* ═══════════════════════════════════════════════
   SmartFinca Sidebar — SAP BO Professional Theme
   Paleta: slate oscuro + acento azul corporativo
   ═══════════════════════════════════════════════ */

:root {
  --sb-bg: #1e293b;
  --sb-bg-deep: #0f172a;
  --sb-border: rgba(255,255,255,.07);
  --sb-text: rgba(255,255,255,.88);
  --sb-muted: rgba(255,255,255,.45);
  --sb-hover: rgba(255,255,255,.06);
  --sb-accent: #3b82f6;
  --sb-accent-soft: rgba(59,130,246,.12);
  --sb-accent-text: #93c5fd;
  --sb-radius: 6px;
  --sb-width: 260px;
  --sidebar-collapsed: 64px;
  --sidebar-width: 260px;
}

body.has-sidebar {
  padding-left: var(--sb-width);
  transition: padding .25s ease;
}

body.has-sidebar.sidebar-collapsed {
  padding-left: var(--sidebar-collapsed);
}

body.has-sidebar .sf-main {
  margin-left: 0;
}

/* ── Sidebar shell ────────────────────────────── */
.sf-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sb-width);
  height: 100vh;
  background: var(--sb-bg);
  color: var(--sb-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sb-border);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: .82rem;
}

/* ── Header ───────────────────────────────────── */
.sf-sidebar__header {
  padding: 16px 16px 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--sb-border);
  background: var(--sb-bg-deep);
  flex-shrink: 0;
}

.sf-sidebar__header .sf-title {
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.1;
  color: #fff;
}

.sf-sidebar__header .sf-subtitle {
  font-size: .6rem;
  color: var(--sb-muted);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: .03em;
}

/* ── Search ───────────────────────────────────── */
.sf-sidebar__search {
  padding: 10px 12px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--sb-border);
}

.sf-search-label {
  font-size: .6rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sb-muted);
  margin-bottom: 6px;
  padding-left: 2px;
}

.sf-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(0,0,0,.2);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  transition: border-color .2s, box-shadow .2s;
  overflow: hidden;
}

.sf-search-wrap:focus-within {
  border-color: var(--sb-accent);
  box-shadow: 0 0 0 2px rgba(59,130,246,.15);
}

.sf-search-icon {
  position: absolute;
  left: 10px;
  font-size: .75rem;
  color: var(--sb-muted);
  pointer-events: none;
  transition: color .2s;
}

.sf-search-wrap:focus-within .sf-search-icon {
  color: var(--sb-accent-text);
}

.sf-search-input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--sb-text);
  font-size: .8rem;
  padding: 8px 30px 8px 32px;
  outline: none;
}

.sf-search-input::placeholder {
  color: var(--sb-muted);
}

.sf-search-clear {
  position: absolute;
  right: 8px;
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  border: none;
  color: var(--sb-text);
  cursor: pointer;
  font-size: .55rem;
  padding: 0;
  flex-shrink: 0;
}

.sf-search-clear:hover {
  background: rgba(255,255,255,.2);
}

.sf-search-hint {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 5px;
  font-size: .62rem;
  color: var(--sb-muted);
  opacity: .6;
  padding-right: 2px;
}

.sf-search-wrap:focus-within + .sf-search-hint {
  opacity: 0;
}

.sf-search-hint kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 0 5px;
  font-size: .6rem;
  font-family: inherit;
  line-height: 1.6;
  color: var(--sb-text);
}

.sf-search-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 28px 12px 16px;
  gap: 6px;
  color: var(--sb-muted);
  font-size: .8rem;
  text-align: center;
}

.sf-search-empty i { font-size: 1.4rem; opacity: .4; }
.sf-search-empty.visible { display: flex; }
.sf-nav-item.sf-search-hidden { display: none !important; }
.sf-nav-section.sf-section-empty { display: none !important; }

/* ── Nav scroll ───────────────────────────────── */
.sf-sidebar__scroll {
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px;
  flex: 1 1 auto;
}

.sf-sidebar__scroll::-webkit-scrollbar { width: 4px; }
.sf-sidebar__scroll::-webkit-scrollbar-track { background: transparent; }
.sf-sidebar__scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,.12);
  border-radius: 4px;
}
.sf-sidebar__scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,.2);
}

/* ── Collapsible groups ───────────────────────── */
.sf-nav-group {
  margin-bottom: 2px;
}

.sf-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  border-radius: var(--sb-radius);
  color: var(--sb-muted);
  padding: 8px 10px;
  cursor: pointer;
  text-align: left;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: color .15s, background .15s;
  user-select: none;
}

.sf-group-header:hover {
  color: var(--sb-text);
  background: var(--sb-hover);
}

.sf-nav-group.sf-group-open .sf-group-header {
  color: var(--sb-accent-text);
  background: transparent;
}

.sf-group-icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 11px;
  opacity: .7;
}

.sf-nav-group.sf-group-open .sf-group-icon {
  opacity: 1;
}

.sf-group-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sf-group-badge {
  font-size: .58rem;
  font-weight: 600;
  background: rgba(255,255,255,.08);
  color: var(--sb-muted);
  border-radius: 8px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sf-nav-group.sf-group-open .sf-group-badge {
  background: var(--sb-accent-soft);
  color: var(--sb-accent-text);
}

.sf-group-arrow {
  font-size: .55rem;
  flex-shrink: 0;
  transition: transform .2s ease;
  opacity: .5;
}

.sf-nav-group.sf-group-open .sf-group-arrow {
  transform: rotate(90deg);
  opacity: .8;
}

/* ── Child items ──────────────────────────────── */
.sf-group-items {
  overflow: hidden;
  max-height: 0;
  transition: max-height .28s ease;
  margin-left: 18px;
  padding-left: 10px;
  border-left: 1px solid rgba(255,255,255,.08);
}

.sf-nav-group.sf-group-open .sf-group-items {
  border-left-color: rgba(59,130,246,.25);
}

.sf-group-items .sf-item {
  margin-bottom: 1px;
  padding: 7px 10px;
  font-size: .8rem;
  border-radius: var(--sb-radius);
  position: relative;
  color: rgba(255,255,255,.7);
  background: transparent;
}

.sf-group-items .sf-item:hover {
  background: var(--sb-hover);
  color: var(--sb-text);
}

.sf-group-items .sf-item.active {
  background: var(--sb-accent-soft);
  color: var(--sb-accent-text);
  font-weight: 600;
  border-bottom: none;
  box-shadow: none;
}

.sf-group-items .sf-item::before {
  display: none;
}

/* ── Base items ───────────────────────────────── */
.sf-section {
  font-size: .62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--sb-muted);
  margin: 14px 8px 6px;
  font-weight: 600;
}

.sf-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--sb-radius);
  text-decoration: none;
  color: inherit;
  margin-bottom: 1px;
  transition: background .15s ease, color .15s ease;
}

.sf-item:hover {
  background: var(--sb-hover);
  color: #fff;
}

.sf-item:focus-visible {
  outline: 2px solid rgba(59,130,246,.4);
  outline-offset: 1px;
}

.sf-item[aria-current="page"],
.sf-item.active {
  background: var(--sb-accent-soft);
  color: var(--sb-accent-text);
  font-weight: 600;
  border-bottom: none;
  box-shadow: none;
}

.sf-item__icon {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
}

.sf-item__icon i {
  width: 18px;
  font-size: 14px;
}

.sf-item__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Account footer ───────────────────────────── */
.sf-sidebar__account {
  padding: 8px;
  border-top: 1px solid var(--sb-border);
  background: var(--sb-bg-deep);
  flex-shrink: 0;
}

.sf-account-group {
  display: grid;
  gap: 1px;
}

.sf-account-group .sf-item {
  margin-bottom: 0;
}

.sf-sidebar__account .sf-user-card {
  margin-top: 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--sb-radius);
  background: rgba(255,255,255,.04);
}

.sf-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,.1);
}

.sf-user-name {
  font-size: .78rem;
  font-weight: 600;
  color: var(--sb-text);
}

.sf-user-role {
  font-size: .65rem;
  color: var(--sb-muted);
}

/* ── Mobile ───────────────────────────────────── */
.sf-mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1200;
  width: 40px;
  height: 40px;
  border-radius: var(--sb-radius);
  background: var(--sb-bg);
  color: var(--sb-text);
  border: 1px solid var(--sb-border);
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  align-items: center;
  justify-content: center;
}

@media (max-width: 1024px) {
  body.has-sidebar {
    padding-left: 0;
  }

  .sf-mobile-toggle {
    display: flex;
  }

  .sf-sidebar {
    width: 82vw;
    max-width: 300px;
    transform: translateX(-110%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    z-index: 1100;
    box-shadow: none;
  }

  .sf-sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }

  .sf-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1099;
  }

  .sf-sidebar-backdrop.show {
    display: block;
  }
}
