/* DevTrack Hub - custom overrides
   Edit this file to customize site appearance.
   This file is loaded after the base inline <style> block and after Bootstrap,
   so you can override many styles here. Use increased specificity if needed.
*/

/* ========== Design Tokens (CSS Variables) ========== */
:root {
  --dt-primary: #667eea;
  --dt-primary-dark: #764ba2;
  --dt-sidebar-bg: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --dt-card-radius: 1rem;
  --dt-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --dt-shadow-md: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
  --dt-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --dt-success: #28a745;
  --dt-warning: #ffc107;
  --dt-danger: #dc3545;
  --dt-info: #17a2b8;
}

/* ========== Sidebar Category Headers ========== */
.sidebar-category {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  border-radius: 0.5rem;
  margin: 0.15rem 0;
  transition: background 0.2s;
}
.sidebar-category:hover {
  background: rgba(255, 255, 255, 0.1);
}
.sidebar-chevron {
  font-size: 0.7rem;
  transition: transform 0.3s;
}
.sidebar-category[aria-expanded="true"] .sidebar-chevron {
  transform: rotate(90deg);
}
.sidebar .nav-link.py-1 {
  padding-top: 0.35rem !important;
  padding-bottom: 0.35rem !important;
  font-size: 0.875rem;
}

/* ========== Print Styles ========== */
@media print {
  .sidebar, .navbar, .btn, .alert, .breadcrumb,
  #widgetConfig, [data-bs-toggle="collapse"],
  .modal, .modal-backdrop,
  .field-save-btn { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .col-md-9, .col-lg-8 { width: 100% !important; max-width: 100% !important; flex: 0 0 100% !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; }
  .card-header { background: #f8f9fa !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .badge { border: 1px solid #999 !important; }
  .table { font-size: 0.8rem; }
  .table th, .table td { padding: 0.25rem 0.5rem !important; }
  canvas { max-height: 200px !important; }
  a[href]:after { content: none !important; }
  h1, h2, h3, h5 { page-break-after: avoid; }
}

/* ========== Mobile Responsive ========== */

/* --- Sidebar (mobile) --- */
@media (max-width: 767.98px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: 260px;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease-in-out;
  }
  .sidebar:not(.show) {
    transform: translateX(-100%);
  }
  .main-content { margin-left: 0 !important; }

  /* Sidebar overlay when open */
  .sidebar.show ~ .sidebar-overlay {
    display: block;
  }
}

/* Sidebar overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1035;
}

/* --- Tablet and below (< 992px) --- */
@media (max-width: 991.98px) {
  /* Stack dashboard header vertically */
  .d-flex.justify-content-between.align-items-center.mb-4 {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem;
  }

  /* Dashboard scope toggle + user selector */
  .d-flex.align-items-center {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* User selector - full width on tablet */
  #userSelector {
    width: 100% !important;
    max-width: 250px;
  }

  /* Filter bar inputs - smaller min-width */
  .filter-bar .form-control,
  .filter-bar .form-select {
    min-width: 140px !important;
  }
  .filter-bar input[type="search"].form-control {
    min-width: 180px !important;
  }
}

/* --- Mobile (< 768px) --- */
@media (max-width: 767.98px) {
  /* Typography */
  h1, .h1 { font-size: 1.5rem !important; }
  h2, .h2 { font-size: 1.25rem !important; }
  h3, .h3 { font-size: 1.1rem !important; }

  /* Cards */
  .card-body { padding: 0.75rem !important; }
  .metric-card h2 { font-size: 1.5rem; }

  /* Tables - smaller text, better scroll */
  .table-responsive { font-size: 0.8rem; }
  .table th, .table td {
    padding: 0.4rem 0.5rem !important;
    white-space: nowrap;
  }

  /* Flex gaps */
  .d-flex.gap-3 { gap: 0.5rem !important; }
  .d-flex.gap-2 { gap: 0.25rem !important; }

  /* Buttons - touch-friendly minimum size */
  .btn {
    min-height: 38px !important;
    padding: 0.375rem 0.625rem !important;
  }
  .btn-sm {
    min-height: 34px !important;
    padding: 0.3rem 0.5rem !important;
  }

  /* Dashboard header - full stack */
  .d-flex.justify-content-between.align-items-center.mb-4 {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem;
  }
  .d-flex.justify-content-between.align-items-center.mb-4 > div:last-child {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* User selector - full width */
  #userSelector {
    width: 100% !important;
  }

  /* Filter bar - stack vertically */
  .filter-bar .form-control,
  .filter-bar .form-select {
    min-width: 100% !important;
    width: 100% !important;
  }
  .filter-bar input[type="search"].form-control {
    min-width: 100% !important;
  }
  .filter-bar .row > [class*="col-"] {
    margin-bottom: 0.5rem;
  }

  /* Statistics cards - 2 per row on mobile */
  .row > .col-md-3 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  /* Breadcrumbs */
  .breadcrumb {
    font-size: 0.8rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* Modals - full width on mobile */
  .modal-dialog {
    margin: 0.5rem !important;
    max-width: calc(100% - 1rem) !important;
  }

  /* Tabs - scrollable on mobile */
  .nav-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .nav-tabs::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link {
    white-space: nowrap;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.85rem;
  }

  /* Board view - narrower columns */
  .board-column,
  [style*="min-width: 280px"] {
    min-width: 240px !important;
    max-width: 280px !important;
  }

  /* Hide less important table columns on mobile */
  .table .d-none-mobile,
  .table .hide-mobile {
    display: none !important;
  }

  /* Page actions - stack buttons */
  .page-actions,
  .d-flex.gap-2.mb-3 {
    flex-wrap: wrap !important;
  }

  /* Badge adjustments */
  .badge {
    font-size: 0.7rem !important;
    padding: 0.3em 0.5em !important;
  }

  /* Progress bars in tables */
  .progress {
    min-width: 60px;
  }
}

/* --- Small phones (< 576px) --- */
@media (max-width: 575.98px) {
  /* Statistics cards - full width on very small screens */
  .row > .col-md-3 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  /* Even smaller text */
  .table-responsive { font-size: 0.75rem; }
  .table th, .table td {
    padding: 0.3rem 0.4rem !important;
  }

  /* Compact card headers */
  .card-header {
    padding: 0.5rem 0.75rem !important;
  }
  .card-header h5,
  .card-header .h5 {
    font-size: 0.95rem !important;
  }

  /* Scope toggle - full width */
  .btn-group[role="group"] {
    width: 100%;
  }
  .btn-group[role="group"] .btn {
    flex: 1;
  }

  /* Quick actions button - full width */
  .d-flex.align-items-center > .btn-primary:last-child {
    width: 100%;
  }

  /* Sidebar slightly narrower for very small screens */
  .sidebar {
    width: 240px !important;
  }

  /* Forms - labels smaller */
  .form-label {
    font-size: 0.8rem !important;
  }
}

/* ========== Accessibility ========== */
*:focus-visible {
  outline: 2px solid var(--dt-primary);
  outline-offset: 2px;
}
.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}
.btn:focus-visible {
  box-shadow: 0 0 0 0.25rem rgba(102, 126, 234, 0.4);
}

/* Example: increase spacing for the preferences quick-links row
   Option A (recommended): add the class `extra-vertical-space` to the row in the template.
   <div class="row extra-vertical-space"> ... </div>
*/
.extra-vertical-space {
  margin-bottom: 5.5rem !important;
}

/* Spacer used between quick-links and collapsible cards on preferences page */
.preferences-spacer {
  height: 4rem;
}

/* Sidebar tweaks (example) */
.sidebar {
  /* override gradient if needed */
  /* background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%); */
}

/* Notification badge color */
.notification-badge {
  background-color: #e55353;
}

/* Card shadow tweaks */
.card {
  box-shadow: 0 0.5rem 1rem rgba(0,0,0,0.08);
}

/* ========== Form Standardization ========== */
/* Ensure all form inputs have consistent height and appearance */

/* Base form control styles */
.form-control,
.form-select {
  height: 38px !important; /* Standard height for all inputs */
  padding: 0.375rem 0.75rem !important;
  font-size: 0.9375rem !important;
  line-height: 1.5 !important;
  border: 1px solid #ced4da !important;
  border-radius: 0.375rem !important;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

/* Textarea exception - allow natural height */
textarea.form-control {
  height: auto !important;
  min-height: 80px !important;
  resize: vertical !important;
}

/* Input groups - ensure consistent height */
.input-group .form-control,
.input-group .form-select,
.input-group-text {
  height: 38px !important;
  display: flex !important;
  align-items: center !important;
}

/* Date and time inputs */
input[type="date"].form-control,
input[type="time"].form-control,
input[type="datetime-local"].form-control {
  height: 38px !important;
  padding-top: 0.375rem !important;
  padding-bottom: 0.375rem !important;
}

/* Number inputs - ensure spinner buttons don't break layout */
input[type="number"].form-control {
  height: 38px !important;
}

/* Focus states */
.form-control:focus,
.form-select:focus {
  border-color: var(--dt-primary) !important;
  box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25) !important;
}

/* Disabled and readonly states */
.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
  background-color: #e9ecef !important;
  opacity: 1 !important;
}

/* Labels - consistent spacing */
.form-label {
  margin-bottom: 0.5rem !important;
  font-weight: 500 !important;
  font-size: 0.875rem !important;
  color: #495057 !important;
}

/* ========== Filter Bar Standardization ========== */
/* Make filter inputs consistent width */
.filter-bar .form-control,
.filter-bar .form-select {
  min-width: 180px !important;
}

.filter-bar input[type="search"].form-control {
  min-width: 250px !important;
}

/* ========== Request Creation Form ========== */
.create-request-form {
  margin-left: 0;
  margin-right: 0;
}

.create-request-form .row {
  --bs-gutter-x: 1rem;
}

/* Ensure all inputs in create request form follow standard height */
.create-request-form .form-control,
.create-request-form .form-select {
  height: 38px !important;
}

.create-request-form textarea.form-control {
  min-height: 8rem !important;
  height: auto !important;
}

/* ========== Task Creation Form ========== */
/* Ensure task form inputs are consistent */
.task-form .form-control,
.task-form .form-select {
  height: 38px !important;
}

.task-form textarea.form-control {
  min-height: 100px !important;
  height: auto !important;
}

/* ========== Grid Consistency ========== */
/* Ensure columns have consistent padding */
.row.g-3 > [class*="col-"] {
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
}

/* ========== Button Consistency ========== */
/* Force ALL buttons to have the same height for visual consistency */
.btn,
.btn-lg {
  height: 38px !important;
  padding: 0.375rem 0.75rem !important;
  font-size: 0.9375rem !important;
  line-height: 1.5 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

/* Small buttons */
.btn-sm {
  height: 31px !important;
  padding: 0.25rem 0.5rem !important;
  font-size: 0.875rem !important;
}

/* Dropdown toggles */
.dropdown-toggle {
  height: 38px !important;
}

/* Ensure buttons in button groups are aligned */
.btn-group .btn {
  height: 38px !important;
}
