/* ============================================================
   Camila Web – Base CSS
   Based on Selvik_web visual system, adapted for Camila AI branding.
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Brand – Purple / Violet palette for Camila */
  --brand-primary:    #7c3aed;
  --brand-primary-hover: #6d28d9;
  --brand-primary-light: rgba(124, 58, 237, 0.12);
  --brand-secondary:  #a78bfa;
  --brand-dark:       #4c1d95;

  /* Surfaces */
  --color-bg:         #f8fafc;
  --color-surface:    #ffffff;
  --color-border:     rgba(15, 23, 42, 0.08);
  --color-border-strong: rgba(15, 23, 42, 0.15);

  /* Text */
  --text-primary:     #0f172a;
  --text-secondary:   #475569;
  --text-muted:       #94a3b8;
  --text-inverse:     #f8fafc;

  /* Sidebar */
  --sidebar-bg:       #1e1b4b;
  --sidebar-text:     rgba(248, 250, 252, 0.75);
  --sidebar-text-active: #ffffff;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(124, 58, 237, 0.35);
  --sidebar-width:    240px;
  --sidebar-collapsed-width: 64px;

  /* Topbar */
  --topbar-height:    56px;
  --topbar-bg:        rgba(255, 255, 255, 0.95);
  --topbar-border:    var(--color-border);

  /* Radius */
  --radius-sm:  0.375rem;
  --radius-md:  0.5rem;
  --radius-lg:  0.75rem;
  --radius-xl:  1rem;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md:  0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg:  0 12px 32px rgba(15, 23, 42, 0.12);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover { color: var(--brand-primary-hover); }

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

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-base);
}

.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1040;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}

.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.sidebar-nav .nav-link i {
  font-size: 1.15rem;
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

.sidebar-collapsed .sidebar-nav .nav-link span {
  display: none;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logout-form { margin: 0; }

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.sidebar-collapsed .sidebar-logout-btn span {
  display: none;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1035;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.show { display: block; }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  backdrop-filter: blur(8px);
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar .container-fluid {
  height: 100%;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
  color: white;
  font-weight: 700;
  font-size: 1rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-pill);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell {
  flex: 1;
}

/* ── Bootstrap Overrides ───────────────────────────────────── */
.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-primary:hover, .btn-primary:focus {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
}

.btn-primary:active {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

.form-control:focus, .form-select:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 0.25rem rgba(124, 58, 237, 0.15);
}

.text-primary { color: var(--brand-primary) !important; }

/* ── Login Brand Icon ──────────────────────────────────────── */
.login-brand-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-dark));
  color: white;
  font-size: 1.5rem;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }
}

@media (max-width: 575.98px) {
  .topbar-brand .brand-title {
    display: none;
  }
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(15, 23, 42, 0.25); }

/* ── Utilities ─────────────────────────────────────────────── */
.text-muted { color: var(--text-muted) !important; }
