/* ================================================================
   MedOrder Lead Manager - Custom Styles (Medical Blue Theme)
   ================================================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-bg: #0a2d5c;
  --sidebar-hover: #1a4a7a;
  --sidebar-active: #42a5f5;
  --primary: #1565c0;
  --primary-light: #1976d2;
  --top-navbar-height: 56px;
}

/* ----------------------------------------------------------------
   Layout
   ---------------------------------------------------------------- */
body {
  background: #f0f4f8;
  font-family: 'Segoe UI', system-ui, sans-serif;
  margin: 0;
  overflow-x: hidden;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-footer small,
.sidebar.collapsed .sidebar-footer .btn span,
.sidebar.collapsed .sidebar-divider { display: none; }

.sidebar-brand {
  padding: 1.25rem 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  white-space: nowrap;
  color: #90caf9;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .5rem 0;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  padding: .65rem 1rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-hover);
  color: #fff;
  border-left-color: var(--sidebar-active);
  font-weight: 600;
}

.sidebar-nav .nav-link i {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-divider {
  border-top: 1px solid rgba(255,255,255,.1);
  margin: .5rem 0;
}

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

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

.main-content.expanded {
  margin-left: 64px;
}

/* ----------------------------------------------------------------
   Top Navbar
   ---------------------------------------------------------------- */
.top-navbar {
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  height: var(--top-navbar-height);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 2px 4px rgba(0,0,0,.06);
}

/* ----------------------------------------------------------------
   Page Header
   ---------------------------------------------------------------- */
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0a2d5c;
  margin: 0;
}

.page-header {
  border-bottom: 2px solid #e3f2fd;
  padding-bottom: .75rem;
}

/* ----------------------------------------------------------------
   Cards
   ---------------------------------------------------------------- */
.card {
  border: 1px solid #e0e8f0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  border-radius: 10px;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #e0e8f0;
  font-weight: 600;
  border-radius: 10px 10px 0 0 !important;
}

/* ----------------------------------------------------------------
   Stat Cards
   ---------------------------------------------------------------- */
.stat-card {
  border-radius: 12px;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
  transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
}

.stat-card .stat-icon { font-size: 2rem; opacity: .85; }
.stat-card .stat-number { font-size: 2rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; opacity: .85; text-transform: uppercase; letter-spacing: .5px; }

/* ----------------------------------------------------------------
   Tables
   ---------------------------------------------------------------- */
.table th {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #666;
  background: #f8f9fa;
  font-weight: 600;
}

.table-hover tbody tr:hover { background: #e3f2fd; }

/* ----------------------------------------------------------------
   Forms
   ---------------------------------------------------------------- */
.form-label { font-weight: 500; font-size: .875rem; color: #444; }

.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 .2rem rgba(25,118,210,.2);
}

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: #0d47a1;
  border-color: #0d47a1;
}

/* ----------------------------------------------------------------
   Rule Builder
   ---------------------------------------------------------------- */
.rule-card {
  border: 1px solid #bbdefb;
  border-radius: 10px;
  background: #f8fbff;
  margin-bottom: 1rem;
}

.rule-card .rule-header {
  background: #e3f2fd;
  border-radius: 10px 10px 0 0;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

.condition-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: .5rem .75rem;
  border-bottom: 1px solid #e3f2fd;
  flex-wrap: wrap;
}

.condition-row:last-child { border-bottom: none; }
.condition-row select, .condition-row input { font-size: .875rem; }

/* ----------------------------------------------------------------
   Login Page
   ---------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a2d5c 0%, #1565c0 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-card .card-header {
  background: linear-gradient(135deg, #0a2d5c, #1565c0);
  color: #fff;
  text-align: center;
  padding: 2rem 1.5rem;
  border-radius: 16px 16px 0 0;
}

/* ----------------------------------------------------------------
   Charts
   ---------------------------------------------------------------- */
.chart-container { position: relative; height: 280px; }

/* ----------------------------------------------------------------
   DataTables
   ---------------------------------------------------------------- */
.dataTables_wrapper .dataTables_filter input {
  border-radius: 6px;
  border: 1px solid #ced4da;
  padding: .35rem .75rem;
}

.dataTables_wrapper .dataTables_length select { border-radius: 6px; }

/* ----------------------------------------------------------------
   Allocation badge
   ---------------------------------------------------------------- */
.allocation-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  background: #e3f2fd;
  color: #0a2d5c;
  border: 1px solid #bbdefb;
  border-radius: 6px;
  padding: .2rem .6rem;
  font-size: .78rem;
  margin: .1rem;
}

/* ----------------------------------------------------------------
   Public form page
   ---------------------------------------------------------------- */
.form-page {
  background: linear-gradient(135deg, #f0f4f8 0%, #e3f2fd 100%);
  min-height: 100vh;
  padding: 2rem 1rem;
}

.form-page .form-card {
  max-width: 700px;
  margin: 0 auto;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,.12);
}

.form-page .form-card .card-header {
  background: linear-gradient(135deg, #0a2d5c, #1565c0);
  color: #fff;
  padding: 1.75rem;
  border-radius: 0;
}

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .stat-card .stat-number { font-size: 1.5rem; }
}

/* ----------------------------------------------------------------
   Misc
   ---------------------------------------------------------------- */
.cursor-pointer { cursor: pointer; }
.text-blue { color: var(--primary); }
.bg-blue-soft { background: #e3f2fd; }
.border-blue { border-color: #bbdefb !important; }

.flash-container .alert { border-radius: 10px; }

.lead-unallocated { border-left: 3px solid #ff5722; }
.lead-partial     { border-left: 3px solid #ff9800; }
.lead-allocated   { border-left: 3px solid #1976d2; }

.tag-pill {
  display: inline-block;
  background: #e3f2fd;
  color: #0a2d5c;
  border-radius: 12px;
  padding: .15rem .6rem;
  font-size: .75rem;
  margin: .1rem;
}

/* Institution type badges */
.badge-clinica       { background: #e3f2fd; color: #0a2d5c; }
.badge-spital        { background: #fce4ec; color: #880e4f; }
.badge-farmacie      { background: #e8f5e9; color: #1b5e20; }
.badge-laborator     { background: #fff8e1; color: #e65100; }
.badge-cabinet       { background: #f3e5f5; color: #4a148c; }
