/* Main Dashboard Layout Styling */
:root {
  --admin-color: #0d6efd;
  --production-color: #198754;
  --orders-color: #ffc107;
  --sidebar-width: 240px;
  --header-height: 60px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}

/* Dashboard Sidebar */
.dashboard-container {
  display: flex;
  min-height: 100vh;
  position: relative;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.dashboard-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background-color: #f8f9fa;
  border-right: 1px solid #dee2e6;
  max-height: 100vh;
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  transition: all 0.3s ease;
  z-index: 1;
  padding-bottom: 20px;
}

.dashboard-content {
  flex-grow: 1;
  padding: 20px;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: #f9f9f9;
  min-width: 0;
  transition: all 0.3s ease;
}

/* Week Navigation Button Fixes */
#next-week, #prev-week {
  position: relative;
  z-index: 9999;
  pointer-events: auto;
}

/* Mobile Sidebar Fixes */
@media (max-width: 991.98px) {
  .dashboard-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    transform: translateX(-100%);
    z-index: 1000;
  }

  .sidebar-open .dashboard-sidebar {
    transform: translateX(0);
  }

  .dashboard-content {
    margin-left: 0 !important;
    width: 100%;
  }

  .dashboard-container {
    max-width: 100%;
    overflow-x: hidden;
  }
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 70px;
  left: 10px;
  z-index: 1001;
  background-color: white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  box-shadow: 0 0 10px rgba(0,0,0,0.1);
  text-align: center;
  line-height: 40px;
}

/* Mobile adjustments for sidebar toggle */
@media (max-width: 991.98px) {
  .sidebar-toggle {
    top: 110px;
    display: block;
  }
}

.sidebar-nav {
  padding: 15px 0;
}

.sidebar-nav .nav-item {
  margin-bottom: 5px;
}

.sidebar-nav .nav-link {
  color: #495057;
  padding: 10px 15px;
  border-radius: 0;
}

.sidebar-nav .nav-link:hover, 
.sidebar-nav .nav-link.active {
  background-color: #e9ecef;
}

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

.sidebar-category {
  padding: 10px 15px;
  font-weight: bold;
  color: #495057;
  border-left: 4px solid #dee2e6;
  margin-top: 15px;
}

.sidebar-category.admin {
  border-left-color: var(--admin-color);
}

.sidebar-category.production {
  border-left-color: var(--production-color);
}

.sidebar-category.orders {
  border-left-color: var(--orders-color);
}

/* Dashboard Cards */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
  width: 100%;
}

.dashboard-card {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  height: 100%;
  width: 100%;
}

.dashboard-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 15px rgba(0,0,0,0.1);
}

.dashboard-card .card-header {
  padding: 12px 15px;
}

.dashboard-card .card-body {
  padding: 20px;
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.dashboard-card .icon {
  font-size: 36px;
  margin-bottom: 15px;
}

.dashboard-card h5 {
  word-break: break-word;
}

.dashboard-card a {
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
  overflow: hidden;
}

/* Newsfeed */
.newsfeed-card {
  margin-bottom: 30px;
  border-radius: 10px;
  overflow: hidden;
  max-width: 100%;
}

.newsfeed-header {
  cursor: pointer;
  padding: 15px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.newsfeed-body {
  padding: 0;
  transition: max-height 0.35s ease;
  max-width: 100%;
  overflow-x: hidden;
}

.newsfeed-body .card-body {
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Mobile Tab Navigation */
.mobile-tabs {
  display: none;
  overflow-x: auto;
  white-space: nowrap;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #dee2e6;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}

.mobile-tabs::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

.mobile-tab {
  display: inline-block;
  padding: 8px 15px;
  color: #495057;
  text-decoration: none;
  font-weight: 500;
  border-radius: 20px;
  margin-right: 8px;
  font-size: 0.9rem;
}

.mobile-tab.active {
  background-color: #e9ecef;
}

.tab-indicator {
  position: absolute;
  height: 3px;
  bottom: 0;
  transition: all 0.3s ease;
}

/* Responsive Design */
@media (max-width: 991.98px) {
  .dashboard-sidebar {
    transform: translateX(-100%);
  }
  
  .dashboard-content {
    margin-left: 0;
  }
  
  .sidebar-toggle {
    display: flex;
    justify-content: center;
    align-items: center;
  }
  
  .sidebar-open .dashboard-sidebar {
    transform: translateX(0);
  }
  
  .sidebar-open .dashboard-content {
    margin-left: 0;
  }
  
  .mobile-tabs {
    display: flex;
  }
  
  .dashboard-cards {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (max-width: 767.98px) {
  .dashboard-cards {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 15px;
  }
  
  .dashboard-card .icon {
    font-size: 30px;
  }
  
  .dashboard-card .card-body {
    padding: 15px 10px;
  }
  
  .dashboard-card h5 {
    font-size: 16px;
  }
  
  .dashboard-content {
    padding: 15px 10px;
  }
  
  .welcome-card {
    padding: 15px 10px;
  }
  
  .welcome-card h1 {
    font-size: 1.8rem;
  }
  
  .section-container {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .newsfeed-card {
    width: 100%;
  }
  
  /* Fix alert and list content on mobile */
  .alert {
    width: 100%;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
  
  .list-group-item {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}

/* Extra small devices */
@media (max-width: 575.98px) {
  .dashboard-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .dashboard-card .icon {
    font-size: 24px;
  }
  
  .dashboard-card h5 {
    font-size: 14px;
  }
  
  .container {
    padding-left: 10px;
    padding-right: 10px;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  
  .navbar-brand {
    font-size: 1rem;
  }
  
  .navbar {
    padding: 0.5rem;
  }
  
  /* Fix for items with long text that might cause horizontal scroll */
  h5, h4, h3, p, .text-truncate {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Welcome Card */
.welcome-card {
  background-color: #f8f9fa;
  border-radius: 10px;
  padding: 25px;
  margin-bottom: 30px;
  text-align: center;
}

.welcome-card h1 {
  margin-bottom: 10px;
  font-weight: bold;
}

/* Animation for newsfeed expand/collapse */
.icon-rotate {
  transition: transform 0.3s ease;
}

.icon-rotate.open {
  transform: rotate(180deg);
}

/* Table styles for responsive tables */
.table-responsive {
  border-radius: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 0 10px rgba(0,0,0,0.05);
  width: 100%;
}

/* Mobile-responsive table styles */
@media (max-width: 767.98px) {
  .table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
  }
  
  .table th, .table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* Optional: stack buttons in actions column */
  .btn-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  
  .btn-group .btn {
    width: 100%;
    margin-left: 0 !important;
  }
}

/* Bootstrap Icon Sizing */
.bi-large {
  font-size: 1.5rem;
}

/* Mobile Form Responsiveness */
@media (max-width: 767.98px) {
  .mobile-form-container {
    margin-top: 1rem !important;
    margin-bottom: 3rem !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
    padding-bottom: 100px !important;
  }
  
  .mobile-responsive-form {
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Ensure buttons stay accessible */
  .mobile-button-container {
    margin-top: 2rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
  }
  
  /* Add safe area for mobile keyboards */
  body {
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  /* Mobile table improvements */
  .table-responsive {
    border: 0;
    box-shadow: none;
  }
  
  .btn-group-vertical .btn {
    margin-bottom: 2px;
    border-radius: 4px !important;
  }
  
  .btn-group-vertical .btn:last-child {
    margin-bottom: 0;
  }
  
  /* Ensure table cells don't get too cramped */
  .table td {
    padding: 8px 4px;
    vertical-align: middle;
  }
  
  .table th {
    padding: 8px 4px;
    font-size: 0.875rem;
  }
}