:root {
  --primary-color: #0066cc;
  --primary-dark: #0052a3;
  --secondary-color: #ffffff;
  --text-color: #333333;
  --border-color: #e0e0e0;
  --bg-light: #f8f9fa;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-color);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

.navbar-dark {
  background-color: var(
    --branding-primary-color,
    var(--primary-color)
  ) !important;
}

/* Main app container - stretch to fill available space */
#app {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100%;
  margin-bottom: env(safe-area-inset-bottom);
}

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

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

.card {
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.card-header {
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
}

.table {
  background-color: white;
}

.table thead {
  background-color: var(--primary-color);
  color: white;
}

.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    135deg,
    var(--primary-color) 0%,
    var(--primary-dark) 100%
  );
}

.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: 10px;
  overflow: hidden;
}

.login-header {
  background-color: var(--primary-color);
  color: white;
  padding: 30px;
  text-align: center;
}

.login-body {
  padding: 30px;
  background-color: white;
}

.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25);
}

.alert {
  border-radius: 5px;
}

.timesheet-row {
  background-color: white;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 10px;
}

.timesheet-row input,
.timesheet-row select {
  margin-bottom: 5px;
}

.badge-admin {
  background-color: #dc3545;
}

.badge-user {
  background-color: #28a745;
}

.submission-card {
  cursor: pointer;
  transition: transform 0.2s;
}

.submission-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

@media (max-width: 768px) {
  .table-responsive {
    font-size: 0.875rem;
  }

  .card {
    margin-bottom: 15px;
  }

  .timesheet-row {
    padding: 10px;
  }
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
}

.text-primary {
  color: var(--primary-color) !important;
}

.bg-primary {
  background-color: var(
    --branding-primary-color,
    var(--primary-color)
  ) !important;
}

.border-primary {
  border-color: var(--primary-color) !important;
}

/* Force time inputs to use 24-hour format */
input[type="time"] {
  font-variant-numeric: tabular-nums;
}

html[lang="en-GB"] input[type="time"] {
  /* Chrome, Edge, Safari will use 24-hour format with en-GB locale */
}

/* --- Admin translations workspace --- */
.admin-hero {
  background: linear-gradient(135deg, var(--primary-color), #1f6feb);
  color: #ffffff;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.admin-hero h5 {
  margin: 0;
  font-weight: 700;
}

.admin-hero small {
  display: block;
  opacity: 0.9;
}

.pill-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.85rem;
}

.toolbar-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.toolbar-card .btn {
  margin-right: 6px;
  margin-bottom: 6px;
}

.toolbar-card select.form-select-sm,
.toolbar-card input.form-control-sm,
.toolbar-card .input-chip,
.toolbar-card .form-select-sm,
.toolbar-card .form-control-sm {
  min-height: 36px;
  border-color: #d9e2f3;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.05);
}

.toolbar-card select.form-select-sm:focus,
.toolbar-card input.form-control-sm:focus,
.toolbar-card .form-select-sm:focus,
.toolbar-card .form-control-sm:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.12rem rgba(0, 102, 204, 0.18);
}

.glass-card {
  border: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.08);
}

.menu-grid {
  width: 100%;
}

.menu-table-wrapper {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
}

.menu-table thead th {
  background: #f5f7fb;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  color: #344054;
}

.menu-table tbody tr:hover {
  background: #f9fbff;
}

.menu-table td {
  vertical-align: middle;
}

.badge-soft {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 8px;
  background: rgba(32, 122, 255, 0.1);
  color: #205fcf;
  font-weight: 600;
  font-size: 0.8rem;
  width: fit-content;
}

.menu-card label {
  font-weight: 600;
  color: #243b53;
}

.menu-card .form-control-sm {
  border-color: #d9e2f3;
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.05);
}

.menu-card .form-control-sm:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.12rem rgba(0, 102, 204, 0.18);
}

.translations-table-wrapper {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.06);
}

.translations-table {
  margin-bottom: 0;
  font-size: 0.9rem;
}

.translations-table thead th {
  background: #f5f7fb;
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  color: #344054;
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 12px;
  font-size: 0.85rem;
}

.translations-table tbody tr:hover {
  background: #f9fbff;
}

.translations-table td {
  vertical-align: middle;
  padding: 8px 12px;
  height: 42px;
}

.trans-row {
  border-bottom: 1px solid var(--border-color);
}

.trans-row .trans-key {
  color: #667085;
  letter-spacing: 0.3px;
}

.trans-text {
  height: 36px !important;
  padding: 6px 8px !important;
  font-size: 0.9rem !important;
}

.badge-soft {
  background: #eef2ff;
  color: var(--primary-color);
  border-radius: 8px;
  padding: 4px 8px;
  font-weight: 600;
}

.shadow-soft {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.toolbar-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.toolbar-filters .form-label {
  font-weight: 600;
  color: #2d2f34;
}

.input-chip {
  background: #f5f7fb;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 6px 10px;
}

.input-chip input {
  border: none;
  background: transparent;
  outline: none;
  width: 110px;
}

.input-chip .btn {
  padding: 4px 10px;
}

/* Responsive timesheet rows for mobile */
.timesheet-row {
  background-color: #ffffff;
  border: 1px solid #e0e0e0 !important;
  border-radius: 6px !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: box-shadow 0.2s;
}

.timesheet-row:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.timesheet-row .card-body {
  padding: 0.75rem !important;
}

.timesheet-row .form-label {
  font-weight: 600;
  color: #333;
  margin-bottom: 0.35rem !important;
  font-size: 0.85rem;
}

.timesheet-row .form-control-sm {
  font-size: 0.9rem;
  height: 32px;
  padding: 0.3rem 0.45rem;
}

.timesheet-row input[readonly] {
  background-color: #f8f9fa;
  font-weight: 500;
}

.row-inline-lg {
  overflow-x: visible;
  column-gap: 0.3rem;
  row-gap: 0.3rem;
}

.name-col {
  display: none !important;
}

@media (min-width: 992px) {
  .row-inline-lg > .col {
    min-width: 72px;
    max-width: 98px;
  }
  .row-inline-lg .week-col {
    min-width: 60px;
    max-width: 78px;
  }
  .row-inline-lg .name-col {
    display: none !important;
  }
  .row-inline-lg .date-col {
    min-width: 118px;
    max-width: 140px;
  }
  .row-inline-lg .start-col,
  .row-inline-lg .end-col,
  .row-inline-lg .pause-col {
    min-width: 96px;
    max-width: 122px;
  }
  .row-inline-lg .km-col {
    min-width: 70px;
    max-width: 88px;
  }
  .row-inline-lg .delete-col {
    min-width: 38px;
    max-width: 44px;
    padding-top: 1.35rem;
    padding-bottom: 0;
  }
  .row-inline-lg .delete-col .btn {
    height: 32px;
    padding: 0.25rem 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
  }
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
  /* Full-width buttons on mobile */
  .btn-mobile-full {
    width: 100%;
  }

  .timesheet-row .card-body {
    padding: 0.75rem !important;
  }

  .timesheet-row .form-control-sm {
    font-size: 0.95rem;
    min-height: 44px; /* Better touch target */
  }

  .timesheet-row input[type="time"],
  .timesheet-row input[type="date"] {
    min-height: 44px; /* Better touch target */
  }

  .timesheet-row .btn-danger {
    padding: 0.5rem;
    font-size: 1rem;
    min-height: 44px;
  }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991px) {
  .timesheet-row .card-body {
    padding: 0.875rem !important;
  }
}

/* Desktop - cleaner view */
@media (min-width: 992px) {
  .timesheet-row .card-body {
    padding: 1rem !important;
  }
}

/* Invoice header responsive buttons */
.card-header .d-flex {
  flex-wrap: wrap;
}

@media (max-width: 767px) {
  .card-header .d-flex .d-flex {
    width: 100%;
    flex-direction: column;
  }

  .card-header .d-flex .d-flex .btn {
    width: 100%;
  }
}

/* Admin users table responsive */
.table-responsive .table-sm {
  font-size: 0.875rem;
}

@media (max-width: 767px) {
  .table-responsive .table th,
  .table-responsive .table td {
    padding: 0.4rem 0.3rem;
  }

  .table-responsive .btn-group-vertical {
    display: flex;
    flex-direction: row !important;
    gap: 2px;
  }

  .table-responsive .btn-group-vertical .btn {
    flex: 1;
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }

  .table-responsive .btn-group-vertical .btn i {
    margin-right: 0;
  }
}

/* User details row styles */
.user-details-row {
  transition: max-height 0.3s ease-out;
}

.user-details-row.d-none {
  display: none !important;
}

.user-details-row:not(.d-none) {
  animation: slideDown 0.3s ease-out;
}

@media (min-width: 768px) {
  .user-details-row,
  .company-details-row {
    display: none !important;
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-text-layer {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
}
.ai-text-layer span {
  position: absolute;
  transform-origin: 0% 0%;
  white-space: pre;
  pointer-events: auto;
  color: transparent; /* prevent double text */
  background: transparent;
}
.ai-text-layer span:hover {
  outline: 1px dashed #0d6efd;
  background: rgba(13, 110, 253, 0.12);
}
.ai-text-layer span.bg-warning {
  color: transparent; /* keep text invisible even when selected */
  background: rgba(255, 193, 7, 0.35);
  outline: 1px solid rgba(255, 193, 7, 0.8);
}
.toggle-details {
  display: inline-block;
  transition: transform 0.3s ease;
  cursor: pointer;
}

.user-details-row:not(.d-none) ~ .user-row .toggle-details,
.user-row:has(+ .user-details-row:not(.d-none)) .toggle-details {
  transform: rotate(180deg);
}

@media (max-width: 767px) {
  .table-responsive {
    font-size: 0.85rem;
  }

  .user-details-row .d-grid {
    grid-template-columns: 1fr;
  }

  /* Admin portal responsive menu */
  .nav-tabs.flex-column {
    border-bottom: none;
  }

  .nav-tabs.flex-column .nav-item {
    width: 100%;
    border-bottom: 1px solid #dee2e6;
  }

  .nav-tabs.flex-column .nav-link {
    border: none;
    border-radius: 0;
    text-align: left;
    padding: 0.75rem;
    margin-bottom: 0;
  }

  .nav-tabs.flex-column .nav-link.active {
    border-left: 3px solid #0d6efd;
    background-color: #f8f9fa;
  }

  .nav-tabs.flex-column .nav-link:not(.active) {
    border-left: 3px solid transparent;
  }

  /* Two-column menu grid */
  .admin-menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: none;
  }

  .admin-menu-grid .nav-item {
    width: 100%;
    border: 1px solid #dee2e6;
    margin: -1px -1px 0 0;
  }

  .admin-menu-grid .nav-link {
    border: none;
    border-radius: 0;
    text-align: left;
    padding: 0.75rem 0.75rem;
    margin: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
  }

  .admin-menu-grid .nav-link i {
    min-width: 20px;
    text-align: center;
  }

  .admin-menu-grid .nav-link.active {
    background-color: #0d6efd;
    color: white;
  }

  .admin-menu-grid .nav-link:not(.active):hover {
    background-color: #f8f9fa;
  }

  /* Fleet modal select styling - make selected text white */
  #vehicleCompany,
  #vehicleKm {
    background-color: #0d6efd !important;
    color: white !important;
    border-color: #0d6efd !important;
  }

  #vehicleCompany option,
  #vehicleKm option {
    color: black;
    background-color: white;
  }

  #vehicleCompany option:checked,
  #vehicleKm option:checked {
    background: linear-gradient(#0d6efd 0%, #0d6efd 100%), white;
    color: white;
  }
}
