/* ===== VARIABLES ===== */
:root {
  --primary: #1677f2;
  --primary-dark: #1264d1;
  --primary-darker: #082b62;
  --primary-rgb: 22, 119, 242;
  --accent: #55a8ff;
  --sidebar-bg: #082b62;
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --success: #159570;
  --success-dark: #0f7558;
  --danger: #d94b5b;
  --warning: #d89b20;
  --info: #208fc2;
  --light: #f5f8fc;
  --dark: #111827;
  --muted: #718096;
  --text-light: #f8fbff;
  --text-dark: #172033;
  --border-color: #dfe7f1;
  --card-bg: #fff;
  --body-bg: #f3f6fa;
}

/* ===== RESET & BASE ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial,
    sans-serif;
}

html,
body {
  height: 100%;
  background: var(--body-bg);
  color: var(--text-dark);
}

body {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* ===== BACKGROUNDS ===== */
.bg-stock {
  background-image:
    linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.3),
      rgba(var(--primary-rgb), 0.4)
    ),
    url("assets/bg.png");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: fixed;
}

/* ===== LOGIN PAGE LAYOUT ===== */
.login-page {
  display: flex;
  height: 100vh;
  width: 100vw;
  font-weight: 600;
}

.card-container {
  position: fixed;
  right: 0;
  top: 0;
  width: 400px;
  height: 100vh;
  background: linear-gradient(
    180deg,
    #1478ee,
    #1265d4 58%,
    #0a3d87
  );
  border-left: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: -12px 0 30px rgba(5, 35, 81, 0.28);
}

.card-container .form-container h4 {
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.card-container .form-label {
  color: #fff;
  font-weight: 700;
}

.card-container .form-control,
.card-container .form-select {
  min-height: 44px;
  color: #172033;
  background-color: #fff;
  border: 2px solid rgba(5, 35, 81, 0.2);
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(5, 35, 81, 0.12);
}

.card-container .form-control::placeholder {
  color: #68758a;
}

.card-container .form-control:focus,
.card-container .form-select:focus {
  color: #172033;
  background-color: #fff;
  border-color: #082b62;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}

.card-container > .p-4 > .d-flex .btn {
  color: #fff;
  background: rgba(8, 43, 98, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: none;
}

.card-container > .p-4 > .d-flex .btn:hover,
.card-container > .p-4 > .d-flex .btn:focus,
.card-container > .p-4 > .d-flex .btn.active {
  color: #082b62;
  background: #fff;
  border-color: #fff;
}

.card-container .d-grid .btn-primary,
.card-container .d-grid .btn-success {
  min-height: 44px;
  color: #082b62;
  background: #fff;
  border: 2px solid #fff;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(5, 35, 81, 0.2);
}

.card-container .d-grid .btn-primary:hover,
.card-container .d-grid .btn-primary:focus,
.card-container .d-grid .btn-success:hover,
.card-container .d-grid .btn-success:focus {
  color: #fff;
  background: #082b62;
  border-color: #fff;
}

.card-container-right {
  position: fixed;
  left: 0;
  top: 0;
  width: 400px;
  height: 100vh;
  background: linear-gradient(
    180deg,
    var(--primary),
    var(--primary-dark),
    var(--primary-darker)
  );
}

.card-container-right.bg-dark {
  background: linear-gradient(
    180deg,
    var(--primary),
    var(--primary-dark),
    var(--primary-darker)
  ) !important;
}

/* ===== LOGO STYLES ===== */
.dash-logo {
  display: flex;
  height: clamp(75px, 15vh, 125px);
  width: 100%;
  margin: 10px 0 0 10px;
  overflow: hidden;
}

.big-logo {
  display: flex;
  height: clamp(250px, 30vh, 400px);
  width: 100%;
  margin: 30px 0 0 30px;
  overflow: hidden;
}

.dash-logo img,
.big-logo img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.logo-brand {
  max-height: 40px;
  height: auto;
  width: auto;
}

/* ===== SIDEBAR STYLES ===== */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--text-light);
  position: fixed;
  top: 0;
  left: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: all 0.3s;
}

.sidebar .logo {
  font-weight: 700;
  font-size: 20px;
  margin-bottom: 16px;
}

.sidebar nav a {
  display: block;
  padding: 10px;
  border-radius: 8px;
  color: #c7d2fe;
  text-decoration: none;
  margin: 6px 0;
  transition: all 0.3s;
}

.sidebar nav a:hover {
  background: var(--sidebar-hover);
  transform: translateX(5px);
}

.sidebar nav a.active {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text-light);
  box-shadow: 0 4px 6px rgba(67, 97, 238, 0.3);
}

.card-container-right .nav-link {
  color: rgba(255, 255, 255, 0.86) !important;
  border-radius: 8px;
  margin: 4px 0;
  padding: 10px 12px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.card-container-right .nav-link:hover {
  color: #fff !important;
  background: var(--sidebar-hover);
  transform: translateX(3px);
}

.card-container-right .nav-link.active {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.18) !important;
  box-shadow: inset 3px 0 0 #9bd0ff;
}

/* ===== MAIN CONTENT ===== */
.content,
.main-content {
  margin-left: 220px;
  padding: 20px 28px;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.search input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  width: 320px;
}

.profile {
  background: linear-gradient(90deg, #eef2ff, #e6fffa);
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--sidebar-bg);
}

.current-user {
  background-color: #fff3cd !important;
}

/* ===== STATS CARDS ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  background: var(--card-bg);
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
}

.card-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.card-value {
  font-size: 22px;
  font-weight: 600;
}

/* ===== FORMS ===== */
.form-section {
  background-color: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  padding: 30px;
  margin-bottom: 30px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  display: block;
}

.form-control,
.form-select {
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 0.95rem;
  transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb), 0.25);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-row.full {
  grid-template-columns: 1fr;
}

/* ===== BUTTONS ===== */
.button-group {
  display: flex;
  gap: 10px;
  margin-top: 30px;
  justify-content: flex-end;
}

.btn-primary {
  color: #fff;
  background-color: var(--primary);
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  color: var(--text-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(67, 97, 238, 0.3);
}

.btn-success {
  background-color: var(--success);
  color: var(--text-light);
  border: none;
  padding: 10px 25px;
  border-radius: 4px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-success:hover {
  background-color: var(--success-dark);
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.btn-danger {
  background-color: var(--danger);
  color: var(--text-light);
  border: none;
  border-radius: 6px;
  transition: all 0.3s;
}

.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

.btn-cancel {
  background-color: #6c757d;
  color: var(--text-light);
  border: none;
  padding: 10px 25px;
  border-radius: 4px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-cancel:hover {
  background-color: #5a6268;
  box-shadow: 0 2px 8px rgba(108, 117, 125, 0.3);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.875rem;
}

.btn-edit {
  background-color: var(--primary); 
  color: white;
  border: none;
  padding: 5px 10px;
  font-size: 0.85rem;
  border-radius: 4px;
  text-decoration: none;
}
.btn-delete {
  background-color: var(--danger); 
  color: white;
  border: none;
  padding: 5px 10px;
  font-size: 0.85rem;
  border-radius: 4px;
  text-decoration: none;
}

/* ===== TABLES ===== */
.table-responsive {
  border-radius: 8px;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  font-weight: 600;
  color: #495057;
  border-bottom-width: 2px;
  padding: 12px 8px;
}

.table td {
  padding: 12px 8px;
  vertical-align: middle;
}

.table tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

.table tbody tr:nth-child(even) {
  background-color: #f5f5f5;
}

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

.table.table-sm th,
.table.table-sm td {
  white-space: nowrap;
  padding: 8px;
}

/* ===== STATUS BADGES ===== */
.status {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--text-light);
  font-size: 12px;
  display: inline-block;
}

.status.done,
.status-confirmed {
  background-color: #d4edda;
  color: #155724;
}

.status.pending {
  background-color: #fff3cd;
  color: #856404;
}

.status.cancelled,
.status.positive {
  background-color: #f8d7da;
  color: #721c24;
}

.status-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 20px;
  font-weight: 500;
}

.badge-success {
  background-color: #d4edda;
  color: #155724;
}

.badge-warning {
  background-color: #fff3cd;
  color: #856404;
}

/* ===== CHARTS ===== */
.charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 20px;
}

.chart-card {
  background: var(--card-bg);
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(2, 6, 23, 0.04);
}

.chart-card h3 {
  margin: 0 0 8px 0;
  font-size: 15px;
}

.chart-container {
  height: 260px;
  position: relative;
}

.chart-container.small {
  height: 180px;
}

.chart-container.pie {
  height: 240px;
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ===== RECENT ACTIVITY ===== */
.recent {
  background: var(--card-bg);
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(2, 6, 23, 0.04);
}

.table-scroll {
  max-height: 600px;
  overflow-y: auto;
}

/* ===== SEARCH CONTAINER ===== */
.search-container {
  background: var(--light);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

/* ===== UTILITY CLASSES ===== */
.bg-gradient {
  background-image: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.15),
    rgba(255, 255, 255, 0)
  );
}

.shadow-sm {
  box-shadow: 0 6px 18px rgba(32, 41, 55, 0.06) !important;
}

a {
  color: #2563eb;
  text-decoration: none;
}

.action-buttons {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.patient-id-badge {
  background-color: #e9ecef;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.9rem;
}

/* ===== SCROLLBAR STYLES ===== */
#signupForm,
.table-scroll {
  max-height: calc(100vh - 180px);
  overflow-y: auto;
  padding-right: 8px;
}

#signupForm::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar {
  width: 6px;
}

#signupForm::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track {
  background: transparent;
}

#signupForm::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

#signupForm::-webkit-scrollbar-thumb:hover,
.table-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* ===== AUTO-FILL STYLES ===== */
input:-webkit-autofill,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-box-shadow: 0 0 0px 1000px #fff inset;
  box-shadow: 0 0 0px 1000px #fff inset;
}

/* ===== RESPONSIVE STYLES ===== */

/* Large desktops (1200px and up) */
@media (min-width: 1200px) {
  .card-container,
  .card-container-right {
    width: 420px;
  }

  /* Sidebar visible, no navbar */
  .sidebar {
    display: flex !important;
    width: 220px;
    position: fixed;
  }

  .navbar.d-lg-none {
    display: none !important;
  }

  .main-content {
    margin-left: 220px;
  }
}

/* Small desktops (992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
  .card-container,
  .card-container-right {
    width: 400px;
  }

  /* Sidebar visible, no navbar */
  .sidebar {
    display: flex !important;
    width: 220px;
    position: fixed;
  }

  .navbar.d-lg-none {
    display: none !important;
  }

  .main-content {
    margin-left: 220px;
  }
}

.horizontal-gradient {
  background: linear-gradient(
    90deg,
    var(--primary),
    var(--primary-dark),
    var(--primary-darker)
  ) !important;
}

.vertical-gradient {
  background: linear-gradient(
    180deg,
    var(--primary),
    var(--primary-dark),
    var(--primary-darker)
  ) !important;
}

/* Tablets (768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
  .card-container,
  .card-container-right {
    width: 360px;
  }

  /* Hide sidebar, show mobile navbar */
  .sidebar {
    display: none !important;
  }

  .navbar.d-lg-none {
    display: block !important;
  }

  .main-content {
    margin-left: 0;
    padding: 15px 20px;
  }

  .logo-brand {
    max-height: 35px;
	margin-left: 12px;
  }

  .navbar-toggler{
	margin-right: 12px;
  }

  /* Stats cards adjustment for tablets */
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr 1fr;
    gap: 15px;
  }
}

/* Force hide sidebar on tablets */
@media (min-width: 768px) and (max-width: 991px) {
  /* Hide sidebar */
  .card-container-right,
  aside[class*="card-container"] {
    display: none !important;
  }

  /* Show navbar */
  nav.navbar.d-lg-none {
    display: flex !important;
  }

  /* Fix main content - COMPREHENSIVE RESET */
  main.col-12.col-md-10.ms-sm-auto,
  .main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
    padding-left: 15px !important;
    padding-right: 15px !important;
  }

  /* Fix the container and row */
  .container-fluid {
    padding-left: 0 !important;
    padding-right: 0 !important;
    overflow-x: hidden !important;
  }

  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    width: 100% !important;
  }

  /* Remove any leftover gutters */
  .row > * {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Ensure the main content fills the space */
  main {
    padding: 15px !important;
  }

  /* Fix any potential offset classes */
  .offset-md-1,
  .offset-md-2,
  .offset-md-3,
  .offset-lg-1,
  .offset-lg-2,
  .offset-lg-3 {
    margin-left: 0 !important;
  }
}
/* Mobile landscape (576px to 767px) */
@media (min-width: 576px) and (max-width: 767px) {
  .card-container,
  .card-container-right {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    border-radius: 0;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }

  /* Hide sidebar, show mobile navbar */
  .sidebar {
    display: none !important;
  }

  .navbar.d-lg-none {
    display: block !important;
  }

  .main-content {
    margin-left: 0;
    padding: 15px;
  }

  .big-logo {
    display: flex;
    height: 100px;
    width: 100%;
    margin: 8px 0;
    justify-content: center;
    align-items: center;
  }

  .big-logo img {
    max-height: 100%;
    max-width: 80%;
    object-fit: contain;
  }

  .login-page {
    align-items: stretch;
    justify-content: center;
  }

  #signupForm {
    max-height: calc(100vh - 180px);
    width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .logo-brand {
    max-height: 35px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .chart-container {
    height: 200px;
  }

  .action-buttons {
    flex-wrap: wrap;
  }
}

/* Mobile portrait (up to 575px) */
@media (max-width: 575px) {
  .card-container,
  .card-container-right {
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    border-radius: 0;
    overflow-y: auto;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }

  /* Hide sidebar, show mobile navbar */
  .sidebar {
    display: none !important;
  }

  .navbar.d-lg-none {
    display: block !important;
  }

  .main-content {
    margin-left: 0;
    padding: 12px;
  }

  .big-logo {
    display: flex;
    height: 80px;
    width: 100%;
    margin: 5px 0;
    justify-content: center;
    align-items: center;
  }

  .big-logo img {
    max-height: 100%;
    max-width: 90%;
    object-fit: contain;
  }

  .login-page {
    align-items: stretch;
    justify-content: center;
  }

  #signupForm {
    max-height: calc(100vh - 150px);
    width: 100%;
  }

  .card-container > .p-4 {
    width: 100%;
    max-width: 100%;
    padding: 1rem !important;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .logo-brand {
    max-height: 30px;
  }

  .stats {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .chart-container {
    height: 180px;
  }

  .chart-container.small {
    height: 130px;
  }

  .table-scroll {
    max-height: 200px;
  }

  .action-buttons {
    flex-wrap: wrap;
  }

  .btn-sm {
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  .table th,
  .table td {
    padding: 8px 4px;
    font-size: 0.85rem;
  }

  h2 {
    font-size: 1.5rem;
  }

  h4 {
    font-size: 1.2rem;
  }

  .card-value {
    font-size: 1.5rem;
  }
}

/* Very small phones (up to 375px) */
@media (max-width: 375px) {
  .card-container,
  .card-container-right {
    padding: 1rem;
  }

  #signupForm {
    max-height: calc(70vh - 140px);
  }

  .btn-primary,
  .btn-success,
  .btn-cancel {
    padding: 8px 16px;
    font-size: 0.9rem;
  }

  .table-responsive {
    overflow-x: auto;
  }
}

/* ===== ADDITIONAL TABLE STYLES ===== */
.highlight-row { 
  background-color: #fff3cd !important; 
}

.action-buttons { 
  display: flex; 
  gap: 6px; 
}

.btn-edit, 
.btn-delete {
  color: white;
  border: none;
  padding: 5px 10px;
  font-size: 0.85rem;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  display: inline-block;
}

.btn-edit { 
  background-color: var(--primary); 
}

.btn-delete { 
  background-color: #dc3545; 
}

.btn-edit:hover,
.btn-delete:hover {
  opacity: 0.9;
}

/* ===== FINAL DROPDOWN FIX FOR ALL MOBILE SCREENS ===== */

/* Target EVERY screen below 768px - NO EXCEPTIONS */
@media (max-width: 767.98px) {
  /* Force stack on ALL screens */
  .card-body > .d-flex.justify-content-between.align-items-center.mb-1 {
    flex-direction: column !important;
    align-items: flex-start !important;
    width: 100% !important;
  }
  
  /* Label full width */
  .card-body .text-muted.small {
    width: 100% !important;
    margin-bottom: 5px !important;
    white-space: normal !important;
  }
  
  /* Dropdown full width below */
  .card-body select.form-select-sm {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
  }
}

/* Specifically target 363px and below to catch any edge cases */
@media (max-width: 363px) {
  .card-body > .d-flex.justify-content-between.align-items-center.mb-1 {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  
  .card-body .text-muted.small {
    width: 100% !important;
    margin-bottom: 5px !important;
  }
  
  .card-body select.form-select-sm {
    width: 100% !important;
    max-width: 100% !important;
  }
}
