html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Sidebar Styles */
.sidebar {
  width: 250px;
  height: 100vh;
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  transition: all 0.3s ease;
  box-shadow: 2px 0 5px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: center;
  align-items: center;
}

.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.sidebar-logo {
  max-width: 100%;
  height: auto;
  max-height: 40px;
  width: auto;
  margin-bottom: 8px;
}

.sidebar-brand-text {
  color: rgba(233,223,196,1);
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.sidebar .nav-link {
  padding: 12px 20px;
  color: rgba(255,255,255,0.7) !important;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
}

.sidebar .nav-link:hover {
  color: white !important;
  background-color: rgba(255,255,255,0.1);
  border-left-color: #007bff;
}

.sidebar .nav-link.active {
  color: white !important;
  background-color: rgba(255,255,255,0.1);
  border-left-color: #007bff;
}

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

/* Submenu Styles */
.sidebar .nav-link .submenu-arrow {
  transition: transform 0.3s ease;
  font-size: 0.8rem;
}

.sidebar .nav-link[aria-expanded="true"] .submenu-arrow {
  transform: rotate(180deg);
}

.sidebar .collapse .nav-link {
  padding: 12px 20px;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
}

.sidebar .collapse .nav-link:hover {
  background-color: rgba(255,255,255,0.1);
  border-left-color: #007bff;
}

.sidebar .collapse .nav-link.active {
  background-color: rgba(255,255,255,0.1);
  border-left-color: #007bff;
}

/* Prevent submenu from shrinking when expanded */
.sidebar .collapse.show {
  display: block !important;
  height: auto !important;
  overflow: visible !important;
}

.sidebar .collapse.show .nav {
  display: block !important;
  height: auto !important;
}

/* Main Content */
.main-content {
  margin-left: 250px;
  min-height: 100vh;
  background-color: #f8f9fa;
  width: calc(100% - 250px);
  overflow-x: hidden;
}

/* Mobile Responsive */
@media (max-width: 767.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
    z-index: 1050; /* Higher z-index to appear above other content */
    transition: transform 0.3s ease-in-out;
  }
  
  .sidebar.show {
    transform: translateX(0);
    box-shadow: 2px 0 15px rgba(0,0,0,0.3); /* Enhanced shadow when open */
  }
  
  .main-content {
    margin-left: 0;
    width: 100%;
    overflow-x: hidden;
  }
  
  .sidebar-toggle {
    display: block;
  }
  
  .sidebar-logo {
    max-height: 35px;
  }
  
  .sidebar-brand-text {
    font-size: 0.8rem;
  }
  
  /* Ensure mobile toggle buttons are visible and accessible */
  #sidebarToggle {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  
  #sidebarToggleTop {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
  
  /* Add overlay when sidebar is open on mobile */
  .sidebar.show::after {
    content: '';
    position: fixed;
    top: 0;
    left: 280px;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: -1;
    pointer-events: auto;
  }
}

/* Card Styles */
.card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transition: transform 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
}

.card-header {
  background-color: #fff;
  border-bottom: 1px solid #e9ecef;
  border-radius: 10px 10px 0 0 !important;
}

/* Button Styles */
.btn {
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-weight: 500;
}

.btn-primary {
  background-color: #007bff;
  border-color: #007bff;
  border-radius: 6px;
}

.btn-primary:hover {
  background-color: #0056b3;
  border-color: #0056b3;
}

/* Table Styles */
.table {
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.table thead th {
  background-color: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Form Styles */
.form-control {
  border-radius: 6px;
  border: 1px solid #ced4da;
  font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.form-control:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}

.form-label {
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-weight: 500;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-weight: 600;
}

.navbar-brand {
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-weight: 600;
}

.sidebar-header h4 {
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-weight: 600;
}

/* Stats Cards */
.stats-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 15px;
  padding: 20px;
  margin-bottom: 20px;
}

.stats-card h3 {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.stats-card p {
  margin: 5px 0 0 0;
  opacity: 0.9;
  font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Font Utility Classes */
.font-montserrat {
  font-family: 'Montserrat', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.font-roboto {
  font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Data-heavy content should use Roboto for better readability */
.data-content {
  font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Global Table Responsive Fixes */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Global container constraints */
.d-flex {
  max-width: 100%;
  overflow-x: hidden;
}

.card {
  max-width: 100%;
  overflow: hidden;
}

.table {
  margin-bottom: 0;
}

/* Mobile improvements (768px and below) */
@media (max-width: 768px) {
  /* Prevent horizontal scroll on mobile */
  body {
    overflow-x: hidden;
  }
  
  .container-fluid {
    overflow-x: hidden;
    max-width: 100%;
  }
  
  /* Mobile table improvements */
  .table-responsive {
    border: 0;
    font-size: 0.85rem;
  }
  
  .table th,
  .table td {
    padding: 0.5rem 0.25rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  
  /* Make specific columns more flexible on mobile */
  .table th[style*="width: 120px"],
  .table td {
    min-width: 80px !important;
    width: auto !important;
  }
  
  /* Customer/Supplier name columns should wrap */
  .customer-name,
  .supplier-name {
    white-space: normal !important;
    max-width: 120px;
    word-wrap: break-word;
  }
  
  /* Override any page-specific table constraints on mobile */
  .table tbody tr {
    white-space: normal !important;
  }
  
  .table th:nth-child(3),
  .table td:nth-child(3) {
    min-width: 100px !important;
    max-width: 150px !important;
  }
  
  /* Button groups in tables */
  .btn-group .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
}

/* Responsive Utilities */
@media (max-width: 576px) {
  .container-fluid {
    padding-left: 10px;
    padding-right: 10px;
  }
  
  .card-body {
    padding: 10px;
  }
  
  .table-responsive {
    font-size: 0.8rem;
  }
  
  .table th,
  .table td {
    padding: 0.25rem 0.1rem;
    font-size: 0.8rem;
  }
  
  /* Even more compact on very small screens */
  .table th[style*="width: 120px"],
  .table td {
    min-width: 60px !important;
  }
  
  .customer-name,
  .supplier-name {
    max-width: 100px;
    font-size: 0.75rem;
  }
  
  .btn-group .btn {
    padding: 0.2rem 0.3rem;
    font-size: 0.7rem;
  }
  
  /* Reduce main padding on very small screens */
  main.p-4 {
    padding: 0.5rem !important;
  }
  
  /* Ensure page content doesn't exceed viewport */
  main {
    max-width: 100%;
    overflow-x: hidden;
  }
}

/* Badge Colors */
.badge.bg-primary {
  background-color: #a8d8ea !important;
  color: #2c3e50 !important;
}

.badge.bg-secondary {
  background-color: #d1d9e0 !important;
  color: #495057 !important;
}

.badge.bg-success {
  background-color: #a8e6cf !important;
  color: #2d5a3d !important;
}

.badge.bg-warning {
  background-color: #ffd3a5 !important;
  color: #8b5a2b !important;
}

.badge.bg-danger {
  background-color: #ffaaa5 !important;
  color: #8b3a3a !important;
}

.badge.bg-info {
  background-color: #a8e6e6 !important;
  color: #2d5a5a !important;
}