/* UI Enhancement Stylesheet
   Branch: cr/ui-enhancement
   Purpose: Unify fonts, colors, spacing, and component styles across pages
   Notes: Designed to work with current templates without requiring markup changes
*/

/* Optional web font (falls back gracefully if offline) */
@import url('https://fonts.googleapis.com/css2?family=Lato:wght@400;700;900&display=swap');

:root {
  /* Color system */
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 8px 24px rgba(2, 6, 23, 0.06);
  --text: #0f172a;           /* slate-900 */
  --muted: #64748b;          /* slate-500 */

  --primary: #2b7de9;        /* refined blue */
  --primary-600: #1f66c4;
  --primary-50: #e9f0fe;

  --success: #2ecc71;
  --success-600: #26ad5f;
  --danger: #e74c3c;
  --danger-600: #cf3e2f;
  --warning: #f59e0b;

  /* Radii & spacing */
  --radius: 12px;
  --r-sm: 8px;
  --r-xs: 6px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
}

/* Base / reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Lato", sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { max-width: 100%; display: block; }

/* Containers */
.container { max-width: 1080px; margin: 0 auto; padding: 0 var(--space-5); }
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
}

/* Cards / panels */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-5);
}
.card + .card { margin-top: var(--space-5); }
.card h2, .card h3, .card h4 { margin: 0 0 var(--space-3) 0; }

/* Typography */
.h1, h1 { font-size: 1.75rem; line-height: 1.3; margin: 0; font-weight: 600; }
.h2, h2 { font-size: 1.35rem; line-height: 1.35; font-weight: 600; }
.h3, h3 { font-size: 1.1rem; line-height: 1.4; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-weight: 600;
  border-radius: var(--r-xs);
  border: 1px solid transparent;
  background: var(--primary);
  color: #fff !important;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease, transform .02s ease;
}
.btn:hover { background: var(--primary-600); }
.btn:active { transform: translateY(1px); }
.btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(43,125,233,0.25); }
/* Prevent underline on button-like anchors */
a.btn, a.btn:hover, a.btn:focus, a.btn:active,
.btn, .btn:hover, .btn:focus, .btn:active { text-decoration: none !important; }

.btn.secondary { background: #fff; color: var(--text) !important; border-color: var(--border); }
.btn.secondary:hover { background: var(--primary-50); border-color: var(--primary); }

.btn.success, .btn-activate { background: var(--success); }
.btn.success:hover, .btn-activate:hover { background: var(--success-600); }

.btn.danger, .btn-danger, .btn-deactivate { background: var(--danger); }
.btn.danger:hover, .btn-danger:hover, .btn-deactivate:hover { background: var(--danger-600); }

/* Inline form helper */
.inline { display: inline; }
.inline-form { display: inline-flex; align-items: center; gap: var(--space-3); }

/* Forms */
label { font-weight: 600; margin-bottom: 6px; display: inline-block; }
/* Ensure controls inherit the global font */
input, select, textarea, button { font: inherit; font-family: inherit; }
input[type="text"], input[type="password"], input[type="time"], input[type="date"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--r-xs);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,125,233,0.2);
}

/* Compact inputs in inline forms (e.g., header toolbars) */
.inline-form input[type="text"],
.inline-form input[type="password"],
.inline-form input[type="time"],
.inline-form input[type="date"],
.inline-form select {
  width: auto;
  min-width: 160px;
  max-width: 260px;
}

/* Admin pick date form inline and fixed width input */
form[action="/admin"] { display: inline-flex; align-items: center; gap: var(--space-3); }
form[action="/admin"] input[type="date"] { width: 200px; min-width: 200px; max-width: 200px; }

@media (max-width: 720px) {
  form[action="/admin"] { display: flex; flex-wrap: wrap; }
  form[action="/admin"] input[type="date"] { width: 100%; min-width: 0; max-width: none; }
}

/* Compact widths for technician entry row */
.form-row .form-field input[type="text"] { max-width: 180px; }
.form-row .form-field input[type="time"] { width: 120px; }
.form-row .form-field select { width: 120px; }
.form-row .form-field button { padding: 10px 14px; }

/* Stack fields to full width on small screens */
@media (max-width: 720px) {
  .inline-form input[type="text"], .inline-form input[type="password"], .inline-form input[type="time"], .inline-form input[type="date"], .inline-form select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  .form-row .form-field input, .form-row .form-field select { width: 100%; max-width: none; }
}

/* Form layout utilities */
.form-row { display: flex; flex-wrap: wrap; gap: var(--space-3); align-items: flex-end; }
.form-field { display: flex; flex-direction: column; min-width: 140px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td {
  border: 1px solid var(--border);
  padding: 10px;
  text-align: center;
}
th {
  background: #f3f6fb;
  color: #0b1220;
}
tr:nth-child(even) td { background: #fbfdff; }

.table-responsive { overflow-x: auto; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); }
.table-responsive table { margin: 0; border: 0; }
.table-responsive th, .table-responsive td { border-left: 0; border-right: 0; }

/* Alerts */
.alert { border-radius: var(--r-xs); padding: 10px 12px; border: 1px solid var(--border); }
.alert.success { background: #e6ffed; border-color: #b7f3c7; color: #065f46; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert.danger { background: #fee2e2; border-color: #fecaca; color: #991b1b; }

/* Layout helpers */
.flex { display: flex; }
.space-between { justify-content: space-between; }
.items-center { align-items: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }
.mt-5 { margin-top: var(--space-5); }

/* Page-specific refinements */
/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: var(--space-5); }
.login-box {
  width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: var(--space-6);
}
.login-box h2 { margin-top: 0; margin-bottom: var(--space-4); }
.login-box .muted { text-align: right; margin-top: var(--space-3); }
/* Login form spacing */
.login-box form { margin-top: var(--space-3); }
.login-box .form-field { margin-bottom: var(--space-4); }
.login-box .form-field:last-child { margin-bottom: 0; }
.login-box button.btn { margin-top: var(--space-2); width: 100%; }

/* Admin/Technician sections labeled as .summary in templates */
.summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-5);
}

/* Note panels */
.note { background: #fff7d6; border: 1px solid #f0d66a; border-radius: var(--r-sm); padding: var(--space-4); }

/* Links */
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 720px) {
  .top-bar { flex-direction: column; align-items: stretch; }
  .inline-form { flex-wrap: wrap; }
  .form-field { min-width: 100%; }
  .btn { width: 100%; }
  .login-box { padding: var(--space-5); }
}

/* Status indicators */
.active-yes { font-weight: 600; color: var(--success); }
.active-no  { font-weight: 600; color: var(--danger); }
