/* ===========================
   Global Layout & Typography
   =========================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #111827, #020617);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;      /* Stack header + content vertically */
  align-items: center;         /* Center shell horizontally */
  justify-content: flex-start; /* Start content at top */
  color: #e5e7eb;
  padding: 24px 12px;
}

/* Container holding each page's content */
.shell {
  width: 100%;
  max-width: 1100px;
}

.card {
  background: #020617;
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* ===========================
   Header / Logo
   =========================== */

.global-header {
  width: 100%;
  text-align: center;
  padding: 16px 0 8px 0;
  margin: 0 0 8px 0;
}

.logo-img {
  height: 48px;
  width: auto;
  display: inline-block;
}

/* ===========================
   Top Row & Headings
   =========================== */

.top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 10px;
  flex-wrap: wrap;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 13px;
  color: #9ca3af;
}

/* Top-right button group (Logout / Users / Settings / New Incident) */
.top-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===========================
   Buttons & Links
   =========================== */

.btn,
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.btn:hover,
.btn-link:hover {
  background: #111827;
  box-shadow: 0 5px 20px rgba(15, 23, 42, 0.7);
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(to right, #f97316, #ec4899);
  border-color: transparent;
  color: #020617;
  font-weight: 600;
}

.btn-primary:hover {
  background: linear-gradient(to right, #fb923c, #f472b6);
}

.btn-danger {
  border-color: #b91c1c;
  color: #fecaca;
}

.btn-danger:hover {
  background: rgba(185, 28, 28, 0.2);
  box-shadow: 0 5px 20px rgba(185, 28, 28, 0.6);
}

.small-btn {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #4b5563;
  background: #020617;
  font-size: 12px;
  cursor: pointer;
  color: #e5e7eb;
}

.small-btn:hover {
  background: #111827;
}

/* ===========================
   Messages / Banners / Spinner
   =========================== */

#message,
#fileMessage {
  margin-top: 6px;
  font-size: 13px;
  min-height: 16px;
  color: #9ca3af;
}

#message {
  margin-bottom: 10px;
}

#message.error,
#fileMessage.error {
  color: #fecaca;
}

#message.success,
#fileMessage.success {
  color: #bbf7d0;
}

#userInfo {
  font-size: 12px;
  color: #9ca3af;
  text-align: right;
  margin-bottom: 4px;
}

/* Simple inline spinner used in banners */
.spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(148, 163, 184, 0.4);
  border-top-color: #f97316;
  margin-right: 6px;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===========================
   Tables (Dashboard & Files)
   =========================== */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #020617;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 8px;
}

thead {
  background: #030712;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid #1f2937;
  text-align: left;
}

th {
  font-weight: 500;
  color: #9ca3af;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: rgba(17, 24, 39, 0.7);
}

/* Status pills on dashboard */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(148, 163, 184, 0.8);
  color: #e5e7eb;
  background: rgba(15, 23, 42, 0.9);
}

.status-Closed {
  border-color: #22c55e;
  color: #bbf7d0;
  background: rgba(22, 163, 74, 0.15);
}

.status-New,
.status-Under\:Review {
  border-color: #f97316;
  color: #fed7aa;
  background: rgba(248, 113, 22, 0.15);
}

.status-Sent\:to\:Repairer,
.status-Awaiting\:Invoice {
  border-color: #60a5fa;
  color: #bfdbfe;
  background: rgba(37, 99, 235, 0.15);
}

/* "View / Edit" + Delete buttons cell */
.actions-cell {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* File links in incident page */
.file-name-link {
  color: #bfdbfe;
  text-decoration: none;
}

.file-name-link:hover {
  text-decoration: underline;
}

/* ===========================
   Forms (Incident / New Incident / Settings)
   =========================== */

form {
  margin-top: 12px;
}

fieldset {
  border: 5px solid rgba(31, 41, 55, 0.9);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 10px 0;
}

legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 500;
  color: #e5e7eb;
}

label {
  display: block;
  font-size: 13px;
  color: #e5e7eb;
  margin-bottom: 6px;
}

label > span {
  display: inline-block;
  margin-bottom: 4px;
}

input,
select,
textarea {
  width: 100%;
  margin-top: 4px;
  padding: 7px 9px;
  border-radius: 10px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
  font-size: 14px;
  box-sizing: border-box;
}

input::placeholder,
textarea::placeholder {
  color: #6b7280;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #f97316;
  box-shadow: 0 0 0 1px rgba(249, 115, 22, 0.45);
  background: #020617;
}

/* Flex row for grouped form fields */
.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.row > div {
  flex: 1;
  min-width: 0;
}

/* Checkboxes + label on same line */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
}

/* File upload row */
.file-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}

.file-row input[type="file"] {
  flex: 1;
}

/* Meta info under incident title (ID, created/updated) */
#meta {
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 10px;
}

/* ===========================
   Settings Page: Tabs & Add Forms
   =========================== */

/* Tab bar */
.tabs {
  display: flex;
  border-bottom: 1px solid #1f2937;
  margin-bottom: 12px;
  gap: 6px;
  flex-wrap: wrap;
}

/* Individual tab buttons */
.tab-btn {
  padding: 6px 12px;
  border-radius: 999px 999px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: #9ca3af;
  font-size: 13px;
  cursor: pointer;
}

.tab-btn.active {
  color: #e5e7eb;
  background: #020617;
  border-color: #4b5563;
  border-bottom-color: #020617; /* blend into card */
}

/* Tab content panels */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* "Add item" inline form at top of each tab */
form.add-form {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

form.add-form input[type="text"] {
  flex: 1;
  min-width: 160px;
}

/* ===========================
   Users Page: Create User Form & Badges
   =========================== */

/* Create user form at the top of Users page */
#createUserForm {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  margin-bottom: 20px;
}

/* Inline text input in user rows (if used) */
.name-input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
  padding: 5px 6px;
  font-size: 13px;
}

/* Role select dropdown in table */
.role-select {
  border-radius: 8px;
  border: 1px solid #4b5563;
  background: #020617;
  color: #e5e7eb;
  padding: 4px 6px;
  font-size: 13px;
}

/* Role badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  margin-left: 4px;
}

.badge-admin {
  background: rgba(248, 113, 22, 0.2);
  color: #fed7aa;
  border: 1px solid #f97316;
}

.badge-staff {
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
  border: 1px solid #94a3b8;
}

/* ===========================
   Incident Page: Message Banner Styles
   =========================== */

#message {
  margin: 10px 0;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  display: none;
  min-height: 0;
}


/* Blue info banner */
#message.info {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(37, 99, 235, 0.15);
  border-color: #60a5fa;
  color: #bfdbfe;
}

/* Green success banner */
#message.success {
  display: block;
  background: rgba(22, 163, 74, 0.15);
  border-color: #22c55e;
  color: #bbf7d0;
}

/* Red error banner */
#message.error {
  display: block;
  background: rgba(185, 28, 28, 0.2);
  border-color: #f97373;
  color: #fecaca;
}

/* Spinner used inside banners */
.spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(148,163,184,0.6);
  border-top-color: #f97316;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}
