/*
  Theme variables and base styles for the application.  Variables are defined
  using CSS custom properties on the :root selector.  These variables
  control primary and secondary colours, backgrounds, text colours and
  border radii.  Dark mode overrides these variables on the `body.dark`
  selector.  Additional utility classes and component styles are defined
  below to provide a consistent look and feel across the app.  The
  definitions mirror those used on the main index.php file so that the
  entire app shares the same palette and layout rules.
*/

:root {
  /* Updated palette inspired by 2025 “digital comfort” trends.  Warm, multi‑tonal
     colours create a welcoming feel and reduce visual fatigue【612942188056491†L152-L160】. */
  --primary: #8b5a2b;      /* mocha-brown, main brand colour */
  --secondary: #4e3620;    /* dark brown for secondary actions */
  --success: #3da35d;      /* soft green for positive actions */
  --warning: #e38d2b;      /* warm orange for warnings */
  --header: #8b5a2b;
  --bg: #f8f5f1;           /* off-white background for comfort */
  --card: #ffffff;
  --text: #352514;         /* dark brown for text */
  --border-radius: 8px;
  --font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  --heading-font: 'Playfair Display', serif;
}

/* Dark mode overrides.  When the `dark` class is present on the body
   element these variables are redefined to darker values. */
/* Dark mode overrides via prefers-color-scheme.  When the user’s system is set
   to dark mode this media query updates the palette automatically.  It is
   complemented by the manual `.dark` class in case users toggle dark mode
   explicitly. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --card: #1b2533;
    --text: #eaeef2;
    --header: #0d1117;
  }
}

body.dark {
  --bg: #0d1117;
  --card: #1b2533;
  --text: #eaeef2;
  --header: #0d1117;
}

/* Base layout and typography */
body {
  font-family: var(--font-family);
  margin: 0;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
}

/* Status badge classes for job lists.  Each status is assigned a
   distinct colour drawn from the warm palette.  These classes are
   referenced in dashboard tables to provide at-a-glance recognition of
   job states.  We intentionally avoid borders and set white text for
   contrast. */
.status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 12px;
  line-height: 1;
  border: none;
}
.status.pending { background: var(--warning); color: #fff; }
.status.in_progress { background: var(--secondary); color: #fff; }
.status.active { background: var(--secondary); color: #fff; }
.status.completed { background: var(--success); color: #fff; }
.status.paid { background: var(--primary); color: #fff; }
.status.cancelled { background: #ef4444; color: #fff; }
header {
  background: var(--header);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--heading-font);
  font-size: 1.25rem;
}
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}
.card {
  background: var(--card);
  border: 1px solid #e5e7eb;
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  margin: 16px 0;
  transition: background 0.2s ease;
  font-family: var(--font-family);
}

/* Buttons use modifier classes to set their background colour.  The base
   `.btn` class defines shared padding, border radius and cursor styles.
   Additional modifiers (e.g. `.secondary`, `.success`, `.warning`)
   override the background colour. */
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--border-radius);
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  font-weight: 600;
  line-height: 1.2;
}
.btn.secondary {
  background: var(--secondary);
}
.btn.success {
  background: var(--success);
}
.btn.warning {
  background: var(--warning);
}
.btn.neutral {
  background: #4b5563;
}

/* Hover and active states for buttons to provide subtle micro‑interactions. */
.btn:hover {
  filter: brightness(1.1);
}
.btn:active {
  transform: scale(0.98);
}

/* Utility classes */
.notice {
  padding: 10px;
  border-radius: 8px;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  margin: 12px 0;
}
input, select, textarea {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  box-sizing: border-box;
}
label {
  display: block;
  margin: 8px 0 4px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 8px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}
th {
  background: #f3f4f6;
  font-weight: 600;
}
tbody tr:hover {
  background: #f9fafb;
}

nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
nav a {
  margin-right: 8px;
  color: var(--text);
  transition: color 0.2s ease;
}
nav a:hover {
  color: var(--primary);
}
.spacer {
  flex: 1;
}

/* Dropdown menu */
.dropdown {
  position: relative;
  display: inline-block;
}
.dropdown .btn {
  background: var(--secondary);
}
.dropdown-content {
  display: none;
  position: absolute;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  min-width: 200px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  z-index: 10;
  left: 0;
  top: 110%;
}
.dropdown-content.right {
  right: 0;
  left: auto;
}
.dropdown-content a {
  display: block;
  padding: 10px 12px;
  text-decoration: none;
  color: #111827;
  transition: background 0.2s ease;
}
.dropdown-content a:hover {
  background: #f3f4f6;
}
/*
  Dropdown menus are now toggled via JavaScript using an `.open` class on the
  `.dropdown` element. The old hover‑based behaviour has been removed to
  improve accessibility on touch devices and to avoid menus staying open
  unintentionally. The menu is displayed when the parent has the `.open`
  class instead of relying on the `:hover` pseudo‑class.
*/
.dropdown.open .dropdown-content {
  display: block;
}

/*
 * Settings menu dropdown.  The settings menu contains many links; to
 * improve usability the dropdown becomes scrollable and uses multiple
 * columns.  Category headings and separators help the user quickly
 * find specific options without overwhelming the interface.
 */
/* Custom styling for the settings dropdown.  Do not set display here;
   use .dropdown.open to control when the menu is visible.  Without this
   the settings menu would always be displayed because the rule would
   override the base display:none. */
.dropdown-content.settings-menu {
  max-height: 70vh;
  overflow-y: auto;
  min-width: 300px;
  width: 100%;
  /* do not specify display here – default remains none */
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px;
  padding: 4px;
}

/* When the settings dropdown is open, display its content as a grid. */
.dropdown.open .dropdown-content.settings-menu {
  display: grid;
}

/* Fix the height of the upcoming chart.  Use !important to override
   inline styles applied by Chart.js which otherwise stretch the canvas. */
#upcomingChart {
  max-height: 240px !important;
  height: 240px !important;
}
.dropdown-content.settings-menu h4 {
  margin: 8px 12px 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.dropdown-content.settings-menu hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 4px 0;
  width: 100%;
}
