/* Custom variables and theme colors */
:root {
  --primary-color: #125985; /* Autobar Blue */
  --primary-hover: #0a3d5d;
  --secondary-color: #D41E2F; /* Autobar Red */
  --secondary-hover: #b31422;
  --dark-accent: #0f172a;
  --light-bg: #f8fafc;
  --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --border-radius: 12px;
}

body {
  background-color: var(--light-bg);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #334155;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Glassmorphic and modern UI widgets */
.autobar-sidebar {
  background: linear-gradient(135deg, var(--primary-color) 0%, #082f49 100%);
  color: #fff;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.1);
}

/* BUG-12: Pin desktop navigation sidebar while main content scrolls */
@media (min-width: 768px) {
  nav.autobar-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    align-self: flex-start;
  }
}

.autobar-sidebar::-webkit-scrollbar {
  width: 6px;
}
.autobar-sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}
.autobar-sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 4px;
}
.autobar-sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

/* BUG-16: Sidebar quick search input */
.sidebar-search-input {
  background-color: rgba(255, 255, 255, 0.12) !important;
  border: 1px solid rgba(255, 255, 255, 0.22) !important;
  color: #ffffff !important;
  border-radius: 8px;
  font-size: 0.82rem;
  padding-left: 2rem;
}
.sidebar-search-input::placeholder {
  color: rgba(255, 255, 255, 0.65);
}
.sidebar-search-input:focus {
  background-color: rgba(255, 255, 255, 0.18) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.15) !important;
  color: #ffffff !important;
}

/* BUG-15: Global live table search bar */
.table-search-wrap {
  position: relative;
  min-width: 240px;
}
.table-search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
  font-size: 0.85rem;
}
.table-search-wrap input {
  padding-left: 2.1rem;
  border-radius: 10px;
}

/* BUG-17: Tom Select Bootstrap 5 integration */
.ts-wrapper {
  min-width: 180px;
}
.ts-wrapper.single .ts-control {
  border-radius: 8px;
  border-color: #dee2e6;
  min-height: 38px;
  padding: 0.375rem 0.75rem;
  background-color: #fff;
}
.ts-wrapper.form-select-sm .ts-control,
.form-select-sm + .ts-wrapper .ts-control {
  min-height: 31px;
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(18, 89, 133, 0.15);
}
.ts-dropdown {
  z-index: 1080 !important;
  border-radius: 10px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.14);
  border-color: #cbd5e1;
}
.ts-dropdown .active {
  background-color: #e0f2fe;
  color: #0f172a;
}

.autobar-sidebar .nav-link {
  color: rgba(255, 255, 255, 0.75);
  font-weight: 500;
  border-radius: 8px;
  margin: 4px 12px;
  padding: 10px 16px;
  transition: all 0.2s ease-in-out;
  display: flex;
  align-items: center;
  text-decoration: none;
}

.autobar-sidebar .nav-link:hover, 
.autobar-sidebar .nav-link.active {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.12);
  transform: translateX(4px);
}

.autobar-sidebar .nav-link i {
  width: 20px;
  margin-right: 8px;
  color: #ffffff;
  background-color: transparent;
}

/* Custom cards */
.dashboard-card {
  border: none;
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
  background: #fff;
}

.dashboard-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.07), 0 8px 10px -6px rgba(0, 0, 0, 0.07);
}

.dashboard-card-primary { border-left: 4px solid var(--primary-color); }
.dashboard-card-secondary { border-left: 4px solid var(--secondary-color); }
.dashboard-card-warning { border-left: 4px solid #f59e0b; }
.dashboard-card-success { border-left: 4px solid #10b981; }

/* Custom Buttons */
.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  border-radius: 8px;
  font-weight: 500;
  padding: 8px 18px;
  transition: all 0.25s;
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-secondary {
  background-color: var(--secondary-color);
  border-color: var(--secondary-color);
  border-radius: 8px;
  font-weight: 500;
  padding: 8px 18px;
  transition: all 0.25s;
}

.btn-secondary:hover, .btn-secondary:focus {
  background-color: var(--secondary-hover);
  border-color: var(--secondary-hover);
}

/* Badges */
.badge-priority-critical { background-color: #ef4444; color: #fff; }
.badge-priority-high { background-color: #f97316; color: #fff; }
.badge-priority-medium { background-color: #eab308; color: #1e293b; }
.badge-priority-low { background-color: #3b82f6; color: #fff; }

.badge-status-pending { background-color: #64748b; color: #fff; }
.badge-status-inprogress { background-color: #3b82f6; color: #fff; }
.badge-status-resolved { background-color: #10b981; color: #fff; }
.badge-status-closed { background-color: #0f172a; color: #fff; }
.badge-status-overdue { background-color: #ef4444; color: #fff; }

/* Tables and forms */
.table-responsive {
  border-radius: var(--border-radius);
  overflow-x: auto;
  box-shadow: var(--card-shadow);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.table th {
  background-color: #f1f5f9;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.25rem rgba(18, 89, 133, 0.15);
}

.autobar-header {
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
}

.nav-section-divider {
  margin: 16px 12px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  text-align: center;
}
.nav-section-divider span {
  position: relative;
  top: 10px;
  background: var(--primary-color);
  padding: 0 8px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ==========================================================================
   RESPONSIVE DESIGN MEDIA QUERIES (MOBILE & TABLET AUTO-ADJUSTMENT)
   ========================================================================== */

/* Tablet & Mobile Screens (< 992px) */
@media (max-width: 991.98px) {
  .task-board {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 1rem !important;
  }
  
  .project-header {
    padding: 1.2rem 1.2rem !important;
    border-radius: 14px !important;
  }

  .tasks-stat-card {
    padding: 1rem 1rem !important;
  }
  
  .tasks-stat-value {
    font-size: 1.6rem !important;
  }

  .autobar-header {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  .modal-dialog {
    margin: 0.5rem auto !important;
    max-width: 96% !important;
  }
}

/* Smartphone Screens (< 576px) */
@media (max-width: 575.98px) {
  .task-board {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  .project-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }

  .project-header h2 {
    font-size: 1.2rem !important;
  }

  .tasks-stat-card {
    gap: 0.75rem !important;
  }

  .tasks-stat-icon {
    width: 42px !important;
    height: 42px !important;
    font-size: 1.1rem !important;
  }

  .btn {
    font-size: 0.85rem !important;
    padding: 0.4rem 0.8rem !important;
  }

  .table th, .table td {
    padding: 0.5rem 0.6rem !important;
    font-size: 0.82rem !important;
  }

  .card {
    border-radius: 12px !important;
  }
  
  .px-md-4 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }

  .subtask-row .col-md-5, 
  .subtask-row .col-md-3, 
  .subtask-row .col-md-1 {
    width: 100% !important;
    margin-bottom: 0.4rem !important;
  }
}