:root {
  --main-color: #002147;
  --sidebar-width: 210px;
  --header-height: 80px;
  --mobile-sidebar-width: 140px; /* Reduced from 270px for smaller screens */
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background-color: #f4f6f9;
  overflow-x: hidden;
}

/* Header - Fixed on all devices */
.navbar {
  background-color: var(--main-color) !important;
  color: #fff;
  height: var(--header-height);
  padding: 0 10px; /* Reduced padding for smaller screens */
  z-index: 1030;
  display: flex;
  align-items: center;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.logo {
  height: 40px;
}

/* Desktop Sidebar - Fixed on desktop only */
.desktop-sidebar {
  width: var(--sidebar-width);
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  background-color: var(--main-color);
  overflow-y: auto;
  z-index: 1020;
  transition: all 0.3s ease;
}

/* Mobile Sidebar - Overlay on mobile */
.mobile-sidebar {
  width: var(--mobile-sidebar-width);
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: -100%;
  background-color: var(--main-color);
  overflow-y: auto;
  z-index: 1040;
  transition: all 0.3s ease;
}

.mobile-sidebar.active {
  left: 0;
  box-shadow: 2px 0 10px rgba(0,0,0,0.2);
}

/* Sidebar links - Shared styles */
.desktop-sidebar a,
.mobile-sidebar a {
  color: #fff;
  display: flex;
  align-items: center;
  padding: 12px 15px;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.desktop-sidebar a i,
.mobile-sidebar a i {
  margin-right: 10px;
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

.desktop-sidebar a:hover,
.mobile-sidebar a:hover {
  background-color: rgba(255,255,255,0.1);
}

/* Main Content */
.container-fluid {
  margin-left: 0;
  padding: 10px; /* Reduced padding for mobile */
  padding-top: calc(var(--header-height) + 10px);
  width: 100%;
  min-height: 100vh;
  font-size: 0.95rem;
}

/* Responsive breakpoints */
/* Very small phones (portrait, <= 360px) */
@media (max-width: 360px) {
  :root {
    --header-height: 56px;
    --mobile-sidebar-width: 80%; /* Percentage-based width for very small screens */
  }
  
  .logo {
    height: 32px;
  }
  
  .navbar {
    padding: 0 8px;
  }
  
  .container-fluid {
    padding: 8px;
    padding-top: calc(var(--header-height) + 8px);
  }
  
  .mobile-sidebar a {
    font-size: 0.85rem;
    padding: 10px 12px;
  }
}

/* Small phones (361px - 576px) */
@media (min-width: 361px) and (max-width: 576px) {
  :root {
    --header-height: 60px;
    --mobile-sidebar-width: 260px; /* Slightly wider for small phones */
  }
  
  .logo {
    height: 35px;
  }
  
  .navbar {
    padding: 0 10px;
  }
  
  .container-fluid {
    padding: 10px;
    padding-top: calc(var(--header-height) + 10px);
  }
}

/* Tablets and small laptops (577px - 768px) */
@media (min-width: 577px) and (max-width: 768px) {
  :root {
    --header-height: 65px;
    --mobile-sidebar-width: 300px; /* Slightly wider for tablets */
  }
  
  .container-fluid {
    padding: 15px;
    padding-top: calc(var(--header-height) + 15px);
  }
}

/* Desktop (769px and up) */
@media (min-width: 769px) {
  .container-fluid {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    padding: 20px;
    padding-top: calc(var(--header-height) + 20px);
  }
  
  .mobile-sidebar {
    display: none !important;
  }
}

/* Mobile menu toggle */
.mobile-menu-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  margin-right: 10px;
  cursor: pointer;
  display: none;
}

/* User info */
.user-info {
  display: none;
}

.user-dropdown {
  position: relative;
  display: inline-block;
}

.user-dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  background-color: var(--main-color);
  min-width: 180px; /* Reduced for mobile */
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  z-index: 1;
  border-radius: 4px;
  padding: 8px;
}

.user-dropdown:hover .user-dropdown-content {
  display: block;
}

/* Mobile user info */
.mobile-user-info {
  display: flex;
  align-items: center;
}

/* Show/hide elements based on device */
@media (max-width: 768px) {
  .desktop-sidebar {
    display: none !important;
  }
  
  .mobile-menu-toggle {
    display: block;
  }
  
  .user-info {
    display: none !important;
  }
  
  .mobile-user-info {
    display: flex !important;
  }
}

@media (min-width: 769px) {
  .mobile-sidebar {
    display: none !important;
  }
  
  .user-info {
    display: block !important;
  }
  
  .mobile-user-info {
    display: none !important;
  }
  
  .mobile-menu-toggle {
    display: none !important;
  }
}

/* Responsive tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
}

/* Responsive tables */
.table-responsive-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 20px;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.table {
  width: 100%;
  margin-bottom: 0;
  background-color: #fff;
}

.table-bordered {
  border: 1px solid #dee2e6;
}

.table-hover tbody tr:hover {
  background-color: rgba(0,33,71,0.05);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0,0,0,0.02);
}

.table th {
  background-color: var(--main-color);
  color: #fff;
  padding: 10px;
  font-size: 0.85rem; /* Slightly smaller for mobile */
  white-space: nowrap;
}

.table td {
  padding: 8px 10px;
  vertical-align: middle;
  font-size: 0.85rem;
}

/* Special handling for very small screens */
@media (max-width: 360px) {
  .table th, 
  .table td {
    padding: 6px 8px;
    font-size: 0.8rem;
  }
}

/* Cards */
.card {
  background-color: #fff;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  padding: 12px;
}

.card h5 {
  font-size: 1rem; /* Smaller for mobile */
  margin-bottom: 12px;
  color: var(--main-color);
}

/* Forms */
.form-control {
  font-size: 0.85rem;
  padding: 6px 10px;
}

.btn {
  font-size: 0.85rem;
  padding: 6px 12px;
}

/* Modal */
.modal-content {
  border-radius: 8px;
}

.modal-title {
  font-size: 1rem;
}

/* Utility classes */
.text-small {
  font-size: 0.75rem !important;
}

.py-10 {
  padding-top: 10px;
  padding-bottom: 10px;
}