/* =======================================================
   OpenSpaces Main Styles — userhome & index
   Depends on: colors.css
   ======================================================= */

/* ---- Layout / Structure ---- */
*,
*::before,
*::after { box-sizing: border-box; }

body {
  background: var(--surface-0);
  color: var(--text-main);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, Helvetica, Arial, sans-serif;
  margin: 0;
}

.wrap {
  max-width: 980px;
  margin: 24px auto;
  padding: 0 16px;
}

/* ---- Header ---- */
.mm-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.mm-header .mm-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}

.mm-user-controls a {
  color: var(--text-main);
  opacity: 0.9;
}

.mm-user-controls a:hover {
  opacity: 1;
  text-decoration: underline;
}

.mm-clock {
  color: var(--action-warn);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  min-width: 4.5ch;
  text-align: right;
  display: inline-block;
}

/* ---- Cards ---- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  margin: 16px 0;
}

.card .hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.card .bd {
  padding: 16px;
}

/* ---- Utilities ---- */
.small { font-size: 12px; }
.muted { color: var(--text-muted); }
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.pill {
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  display: inline-block;
}

.break { overflow-wrap: anywhere; word-break: break-word; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* =======================================================
   Worktime Summary (inline row)
   ======================================================= */
.kv-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  line-height: 1.4;
  margin-top: 6px;
}
.kv-inline span { white-space: nowrap; }
.kv-inline strong { color: var(--text-muted); margin-right: 4px; }

/* =======================================================
   Shift Action Buttons
   ======================================================= */
.btnbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.btnbar button {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  flex: 0 0 auto;
  width: auto;
  transition: background-color 0.2s, border-color 0.2s;
  outline: none;
}

/* Focus ring */
.btnbar button:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* ---- Per-Kind Colors ---- */
button[data-kind="start_shift"],
button[data-kind="change_truck"],
button[data-kind="end_break"] {
  background-color: var(--action-ok);
  border-color: var(--action-ok);
  color: #fff;
}
button[data-kind="start_shift"]:hover,
button[data-kind="change_truck"]:hover,
button[data-kind="end_break"]:hover {
  background-color: var(--action-ok-hover);
}

button[data-kind="start_break"] {
  background-color: var(--action-warn);
  border-color: var(--action-warn);
  color: #000;
}
button[data-kind="start_break"]:hover {
  background-color: var(--action-warn-hover);
}

button[data-kind="end_shift"] {
  background-color: var(--action-stop);
  border-color: var(--action-stop);
  color: #fff;
}
button[data-kind="end_shift"]:hover {
  background-color: var(--action-stop-hover);
}

/* =======================================================
   Recent Activity Table
   ======================================================= */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; }

table.recent th,
table.recent td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

table.recent th { color: var(--text-muted); font-weight: 600; }

/* Column sizing */
table.recent .col-time { width: 72px; }
table.recent .col-evt  { width: 1%; }
table.recent .col-addr { width: 34%; }
table.recent .col-act  { width: 84px; text-align: right; }

/* Wrapping: ONLY allow mid-word wrap on Address (col 3), not Actions */
table.recent td:nth-child(3) {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Map / Edit row */
table.recent td .act {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;      /* allows wrapping as a unit */
  gap: 8px;             /* space between Edit and Map */
  line-height: 1.3;
  word-break: normal;   /* prevent mid-word breaking */
  overflow-wrap: normal;
}

table.recent td .act a {
  white-space: nowrap;          /* keep “Edit” and “Map” intact */
  color: var(--text-main);      /* restore link color */
  font-size: 13px;              /* slightly smaller than cell text */
  text-decoration: none;        /* clean look */
}

table.recent td .act a:hover {
  text-decoration: underline;   /* hover affordance */
}

/* ---- Mobile Adjustments ---- */
@media (max-width: 600px) {
  table.recent th,
  table.recent td {
    padding: 8px 6px;
    font-size: 13px;
  }

  /* Tighter time; event shrinks; address can grow; actions keep minimum */
  table.recent .col-time { width: 44px; }           /* was 26px: give digits some room */
  table.recent .col-evt  { width: 18%; }            /* flexible tag/pill */
  table.recent .col-addr { width: auto; }           /* <-- let Address take remaining space */
  table.recent .col-act  {
    width: auto;                                    /* stop hard 84px */
    min-width: 70px;                                 /* enough for “Edit  Map” */
    text-align: right;
    white-space: nowrap;
  }

  /* let actions wrap to next line cleanly if ultra-narrow */
  table.recent td .act {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
  }
}



/* Animated toggle-style button */
.btn-theme {
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-main);
  border-radius: 20px;
  padding: 6px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color .2s, transform .25s ease;
}

/* Click/active animation */
.btn-theme:active {
  transform: translateX(4px); /* moves right */
}

/* When in light mode, visually nudged left to show toggle state */
:root[data-theme="light"] .btn-theme {
  background: var(--surface-1);
  color: var(--text);
  transform: translateX(-4px); /* visually offset left */
}

/* Optional hover effect */
.btn-theme:hover {
  background: var(--border);
}

/* header alighment  */
.mm-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Keep clock + theme button together */
.left-group {
  display: flex;
  align-items: center;
  gap: 0.5rem; /* spacing between clock and button */
}

.btn-theme {
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-main);
  cursor: pointer;
  transition: background-color 0.2s, transform 0.2s;
}

.btn-theme:hover {
  background: var(--border);
}
/* =======================================================
   Worktime Status Message (Current shift panel)
   ======================================================= */

#worktimeCard .hd {
  display: flex;
  align-items: baseline;
  gap: 10px;
  /* make header text bigger; body stays normal */
  font-size: 16px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  overflow: hidden; /* clip gradients to header only */
}

/* Message text + icon */
#wtMsg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: 0.2px;
  opacity: 0.98;
  transition: color 0.15s ease, opacity 0.2s ease;
}
#wtMsg::before {
  content: '•';
  display: inline-block;
  font-weight: 900;
  transform: translateY(-1px);
  opacity: 0.9;
}

/* Severity colours for the text (useful on neutral header) */
#wtMsg.wt-muted   { color: var(--text-muted); }
#wtMsg.wt-ok      { color: var(--text-main); }
#wtMsg.wt-success { color: var(--green); }
#wtMsg.wt-warn    { color: var(--amber); }
#wtMsg.wt-bad     { color: var(--red); }

#wtMsg.wt-muted::before   { content: '•'; }
#wtMsg.wt-ok::before      { content: '•'; }
#wtMsg.wt-success::before { content: '✅'; }
#wtMsg.wt-warn::before    { content: '⚠️'; }
#wtMsg.wt-bad::before     { content: '⛔️'; }

/* Gentle pulse on problem states */
@keyframes softPulse {
  0%, 100% { opacity: 0.9; transform: translateY(0); }
  50%      { opacity: 1;   transform: translateY(-1px); }
}
#wtMsg.wt-warn, #wtMsg.wt-bad { animation: softPulse 2.2s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { #wtMsg.wt-warn, #wtMsg.wt-bad { animation: none; } }

/* =======================================================
   Status Card — header-only colouring
   ======================================================= */

#worktimeCard {                    /* base card stays neutral */
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: border-color .25s ease;
}
#worktimeCard .bd {                /* keep body/buttons neutral */
  background: var(--surface-1);
  color: var(--text-main);
}

/* Optional border accents per state */
#worktimeCard.card-ok   { border-color: var(--green); }
#worktimeCard.card-warn { border-color: var(--amber-dark); }
#worktimeCard.card-bad  { border-color: var(--red-dark); }

/* Header backgrounds per state — text forced to white */
#worktimeCard .hd { background: var(--surface-1); color: var(--text-main); }
#worktimeCard.card-ok .hd,
#worktimeCard.card-success .hd {
  background: var(--gradient-ok, var(--green));
  color: #fff;
  border-bottom-color: transparent;
}
#worktimeCard.card-warn .hd {
  background: var(--gradient-warn, #f6c445);
  color: #fff; /* force white per request */
  border-bottom-color: transparent;
}
#worktimeCard.card-bad .hd {
  background: var(--gradient-stop, #d04545);
  color: #fff;
  border-bottom-color: transparent;
}

/* Make the status line in the header bigger/whiter */
#worktimeCard .hd #wtMsg {
  font-size: 22px;     /* tweak size here */
  font-weight: 800;
  color: #fff;         /* stays white on coloured headers */
  line-height: 1.2;
}

/* On coloured headers, the dot icon can be hidden if you prefer */
/* Uncomment if you want to hide the dot on heavy headers
#worktimeCard.card-ok    #wtMsg::before,
#worktimeCard.card-warn  #wtMsg::before,
#worktimeCard.card-bad   #wtMsg::before { content: ''; }
*/

/* profile link */
#profileLink:hover {
  background: var(--hover,#333);
  border-color: var(--ok,#888);
}
#profileLink:active {
  background: var(--ok,#444);
}

#profileLink {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid var(--border, #666);
  background: var(--panel, #222);
  color: var(--text, #fff);
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s;
}

/* Light theme overrides */
html[data-theme='light'] #profileLink {
  background: #f3f4f6;       /* light grey */
  border-color: #cbd5e1;
  color: #1e1e1e;            /* dark icon */
}

/* Hover/active feedback for both themes */
#profileLink:hover {
  background: var(--hover, #333);
  border-color: var(--ok, #888);
}
html[data-theme='light'] #profileLink:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}
