/* ============================================================
   ResaNetwork New Frontend — app.css
   Bootstrap 5 base + custom design system
   ============================================================ */

/* ── CSS Variables ───────────────────────────────────────── */
:root {
  --ob-sidebar-bg:       #1e2d3d;
  --ob-sidebar-border:   #2a3f55;
  --ob-sidebar-text:     #b0c4d8;
  --ob-sidebar-hover:    #2a3f55;
  --ob-sidebar-active:   #3a9bd5;
  --ob-sidebar-width:    240px;
  --ob-header-height:    56px;
  --ob-content-bg:       #f5f7fa;
  --ob-card-shadow:      0 1px 4px rgba(0,0,0,.08);
  --ob-primary:          #3a9bd5;
  --ob-primary-dark:     #2980b9;
  --ob-font:             -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--ob-font);
  background:  var(--ob-content-bg);
  color:       #2c3e50;
  font-size:   0.9rem;
  margin: 0;
}

/* ── App shell layout ─────────────────────────────────────── */
.ob-shell {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.ob-sidebar {
  width: var(--ob-sidebar-width);
  min-width: var(--ob-sidebar-width);
  background: var(--ob-sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1040;
  transition: transform .25s ease;
}

.ob-sidebar-brand {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--ob-sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
}
.ob-sidebar-brand .brand-logo {
  width: 44px; height: 40px;
  background: #c0392b;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: .72rem; color: #fff;
  letter-spacing: 1.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.ob-sidebar-brand .brand-name {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
}
.ob-sidebar-brand .brand-sub {
  font-size: .68rem;
  color: var(--ob-sidebar-text);
  font-weight: 400;
}

.ob-nav-section {
  padding: 14px 0 4px;
}
.ob-nav-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #5a7a99;
  padding: 0 20px 6px;
}
.ob-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--ob-sidebar-text);
  text-decoration: none;
  font-size: .84rem;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.ob-nav-item:hover {
  background: var(--ob-sidebar-hover);
  color: #e2ecff;
}
.ob-nav-item.active {
  background: rgba(58,155,213,.15);
  color: #fff;
  border-left-color: var(--ob-sidebar-active);
}
.ob-nav-item .nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  opacity: .8;
}
.ob-nav-item.active .nav-icon { opacity: 1; }

/* Collapsible nav group (e.g. Guest > Guest CRM / Guest Analytics) */
.ob-nav-toggle {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  margin: 0;
  font: inherit;
  color: var(--ob-sidebar-text);
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  outline: none;
  box-shadow: none;
  border-radius: 0;
  cursor: pointer;
  text-align: left;
}
.ob-nav-toggle:focus,
.ob-nav-toggle:focus-visible {
  background: var(--ob-sidebar-hover);
  box-shadow: none;
  outline: none;
}
.ob-nav-toggle::-moz-focus-inner { border: 0; }
.ob-nav-toggle .ob-nav-item-label { flex: 1; }
.ob-nav-toggle .nav-caret {
  font-size: .7rem;
  opacity: .6;
  transition: transform .15s;
}
.ob-nav-group.open .ob-nav-toggle .nav-caret { transform: rotate(180deg); }
.ob-nav-submenu { background: rgba(0,0,0,.12); }
.ob-nav-subitem { padding-left: 44px; font-size: .8rem; }

/* Sidebar footer (user info + logout) */
.ob-sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--ob-sidebar-border);
  padding: 14px 16px;
}
.ob-user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.05);
}
.ob-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--ob-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}
.ob-user-info .name {
  font-size: .82rem;
  font-weight: 600;
  color: #e2ecff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.ob-user-info .role-badge {
  display: inline-block;
  font-size: .62rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  color: #fff;
  margin-top: 1px;
}
.ob-logout-btn {
  display: block;
  text-align: center;
  margin-top: 10px;
  padding: 6px;
  border-radius: 6px;
  color: #7a95b0;
  text-decoration: none;
  font-size: .78rem;
  transition: background .15s, color .15s;
}
.ob-logout-btn:hover {
  background: rgba(220,53,69,.15);
  color: #ff7b7b;
}

/* ── Main content area ────────────────────────────────────── */
.ob-content {
  margin-left: var(--ob-sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Impersonation banner ─────────────────────────────────── */
.ob-impersonation-bar {
  background: #1a0a00;
  border-bottom: 2px solid #e67e22;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: .78rem;
  color: #f0c080;
}
.ob-impersonation-bar .imp-label  { font-weight: 600; color: #e67e22; }
.ob-impersonation-bar .imp-badge  {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
}
.ob-impersonation-bar .imp-timer {
  background: rgba(0,0,0,.4);
  color: #ffd700;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 600;
}
.ob-impersonation-bar .imp-stop {
  margin-left: auto;
  padding: 3px 14px;
  background: #e67e22;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}
.ob-impersonation-bar .imp-stop:hover { background: #d35400; color: #fff; }

/* ── Page header ──────────────────────────────────────────── */
.ob-page-header {
  background: #fff;
  border-bottom: 1px solid #e8ecf0;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.ob-page-header h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  color: #1e2d3d;
}
.ob-page-header .header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ── Main padding ─────────────────────────────────────────── */
.ob-main {
  padding: 24px;
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────── */
.ob-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--ob-card-shadow);
  border: 1px solid #e8ecf0;
}
.ob-card-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e8ecf0;
  font-weight: 600;
  font-size: .88rem;
  color: #1e2d3d;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ob-card-body { padding: 18px; }

/* ── Stat cards ───────────────────────────────────────────── */
.ob-card-hover { transition: box-shadow .15s, transform .15s; }
.ob-card-hover:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); transform: translateY(-2px); }

.ob-stat {
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e8ecf0;
  box-shadow: var(--ob-card-shadow);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.ob-stat-icon {
  width: 46px; height: 46px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.ob-stat-num {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: #1e2d3d;
}
.ob-stat-label {
  font-size: .75rem;
  color: #6c8ebf;
  margin-top: 2px;
}

/* ── Tables ───────────────────────────────────────────────── */
.ob-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.ob-table th {
  background: #f5f7fa;
  color: #5a7a99;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 9px 12px;
  border-bottom: 1px solid #e8ecf0;
  white-space: nowrap;
}
.ob-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.ob-table tbody tr:hover { background: #f8fafc; }
.ob-table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ───────────────────────────────────────────────── */
.ob-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  color: #fff;
}
.ob-badge-active   { background: #198754; }
.ob-badge-inactive { background: #6c757d; }
.ob-badge-warning  { background: #b8860b; }

/* ── Forms ────────────────────────────────────────────────── */
.ob-form-label {
  font-size: .78rem;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 4px;
  display: block;
}
.ob-form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d9e0;
  border-radius: 6px;
  font-size: .85rem;
  color: #2c3e50;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.ob-form-control:focus {
  outline: none;
  border-color: var(--ob-primary);
  box-shadow: 0 0 0 3px rgba(58,155,213,.15);
}
.ob-form-control.error { border-color: #dc3545; }
select.ob-form-control { appearance: none; cursor: pointer; }

/* ── Buttons ──────────────────────────────────────────────── */
.ob-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 6px;
  border: none;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, transform .08s;
  white-space: nowrap;
}
.ob-btn:active { transform: scale(.97); }
.ob-btn:disabled, .ob-btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: auto; /* keep the title tooltip working */
  transform: none !important;
}
.ob-btn:disabled:hover, .ob-btn[disabled]:hover { background: inherit; }
.ob-btn-primary   { background: var(--ob-primary); color: #fff; }
.ob-btn-primary:hover   { background: var(--ob-primary-dark); color: #fff; }
.ob-btn-success   { background: #198754; color: #fff; }
.ob-btn-success:hover   { background: #146c43; color: #fff; }
.ob-btn-danger    { background: #dc3545; color: #fff; }
.ob-btn-danger:hover    { background: #b02a37; color: #fff; }
.ob-btn-secondary { background: #6c757d; color: #fff; }
.ob-btn-secondary:hover { background: #5a6268; color: #fff; }
.ob-btn-outline   { background: transparent; border: 1px solid #d1d9e0; color: #4a5568; }
.ob-btn-outline:hover   { background: #f5f7fa; color: #2c3e50; }
.ob-btn-sm { padding: 4px 10px; font-size: .76rem; }
.ob-btn-xs { padding: 2px 8px;  font-size: .7rem; }

/* ── Alerts ───────────────────────────────────────────────── */
.ob-alert {
  padding: 11px 16px;
  border-radius: 8px;
  font-size: .84rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.ob-alert-danger  { background: #fff2f2; border: 1px solid #ffc1c1; color: #842029; }
.ob-alert-success { background: #f0fff4; border: 1px solid #b2dfdb; color: #155724; }
.ob-alert-info    { background: #e8f4fd; border: 1px solid #b8d9f5; color: #0c4a7a; }
.ob-alert-warning { background: #fffbf0; border: 1px solid #fde68a; color: #78520e; }

/* ── Modal ────────────────────────────────────────────────── */
.ob-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
}
.ob-modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  overflow: hidden;
}
.ob-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e8ecf0;
  font-weight: 700;
  font-size: .95rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ob-modal-body   { padding: 20px; }
.ob-modal-footer { padding: 14px 20px; border-top: 1px solid #e8ecf0; display: flex; gap: 8px; justify-content: flex-end; }
.ob-modal-close  { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #6c757d; line-height: 1; }

/* ── Login page ───────────────────────────────────────────── */
.ob-login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e2d3d 0%, #2a4a6b 50%, #1a3a55 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.ob-login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 24px 80px rgba(0,0,0,.25);
}
.ob-login-logo {
  width: 52px; height: 52px;
  background: var(--ob-primary);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 20px;
}
.ob-login-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 700;
  color: #1e2d3d;
  margin-bottom: 4px;
}
.ob-login-subtitle {
  text-align: center;
  font-size: .8rem;
  color: #6c8ebf;
  margin-bottom: 28px;
}
.ob-input-group {
  position: relative;
  margin-bottom: 16px;
}
.ob-input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #9aafc0;
  font-size: .95rem;
}
.ob-input-group .ob-form-control {
  padding-left: 36px;
}

/* ── Utilities ────────────────────────────────────────────── */
.text-muted-ob { color: #7a95b0 !important; }
.fw-600        { font-weight: 600; }
.gap-8         { gap: 8px; }
.d-flex-center { display: flex; align-items: center; }

/* ── HTMX indicator ────────────────────────────────────────── */
.htmx-indicator {
  opacity: 0;
  transition: opacity 500ms ease-in;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* ── Footer ───────────────────────────────────────────────── */
.ob-footer {
  padding: 12px 24px;
  border-top: 1px solid #e8ecf0;
  background: #fff;
  font-size: .72rem;
  color: #9aafc0;
  text-align: center;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .ob-sidebar {
    transform: translateX(-100%);
  }
  .ob-sidebar.open {
    transform: translateX(0);
  }
  .ob-content {
    margin-left: 0;
  }
}
