* { box-sizing: border-box; }

/* Hide the app until Vue has mounted so raw {{ }} mustaches aren't visible. */
[v-cloak] { display: none; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: #f4f6f8;
  color: #1f2937;
}

header {
  background: #1f2937;
  color: white;
  padding: 0.6rem 1.25rem;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.login-flags {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.flag-btn {
  background: transparent;
  border: 2px solid transparent;
  padding: 0;
  margin: 0;
  width: 28px;
  height: 20px;
  border-radius: 3px;
  cursor: pointer;
  overflow: hidden;
  line-height: 0;
  transition: border-color 0.15s, transform 0.15s;
}

.flag-btn:hover { transform: scale(1.08); background: transparent; }
.flag-btn.active { border-color: #fff; box-shadow: 0 0 0 2px #3b82f6; }
.login-flags .flag-btn.active { border-color: #3b82f6; }
.flag-btn svg { display: block; width: 100%; height: 100%; }

/* Language dropdown in the header */
.lang-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}
.lang-picker .flag-btn.current { border-color: rgba(255,255,255,0.2); }
.lang-picker .chevron {
  color: rgba(255,255,255,0.65);
  font-size: 0.65rem;
  pointer-events: none;
}
.lang-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: white;
  color: #1f2937;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  padding: 0.25rem 0;
  min-width: 150px;
  z-index: 80;
}
.lang-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: transparent;
  border: none;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.85rem;
  color: #1f2937;
  cursor: pointer;
  margin: 0;
  min-height: 0;
}
.lang-option:hover { background: #f3f4f6; }
.lang-option.active { background: #eef2ff; color: #1e40af; font-weight: 600; }
.lang-option .flag-tile {
  width: 22px;
  height: 16px;
  display: inline-flex;
  border-radius: 2px;
  overflow: hidden;
  line-height: 0;
  flex-shrink: 0;
}
.lang-option .flag-tile svg { width: 100%; height: 100%; }

/* Logout: text on desktop, icon on mobile */
.logout-icon { display: none; font-size: 1rem; line-height: 1; }
.logout-btn { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

nav button {
  background: transparent;
  color: white;
  border: 1px solid #4b5563;
  padding: 0.35rem 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

nav button.active,
nav button:hover {
  background: #3b82f6;
  border-color: #3b82f6;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

h2 { margin-top: 0; }

.card {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
}

.row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.row > label, .row > * { flex: 1; min-width: 200px; }

label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #3b82f6;
}

button {
  background: #e5e7eb;
  color: #1f2937;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  margin-right: 0.5rem;
}

button:hover { background: #d1d5db; }

button.primary { background: #3b82f6; color: white; }
button.primary:hover { background: #2563eb; }

button.danger { background: #fee2e2; color: #991b1b; }
button.danger:hover { background: #fecaca; }

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

th, td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.875rem;
}

th { background: #f9fafb; font-weight: 600; }

tfoot td { background: #f9fafb; }

.filters { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.filters label { margin-bottom: 0; flex: 1 1 180px; min-width: 160px; }

.export-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.alert {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  font-size: 0.95rem;
  max-width: 90vw;
  animation: toast-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.alert.error   { background: #ef4444; color: white; }
.alert.success { background: #10b981; color: white; }

.alert.success::before { content: "✓"; font-size: 1.1rem; font-weight: 700; }
.alert.error::before   { content: "!"; font-size: 1.1rem; font-weight: 700;
                          display: inline-flex; width: 1.1rem; height: 1.1rem;
                          align-items: center; justify-content: center;
                          background: rgba(255, 255, 255, 0.25); border-radius: 999px; }

@keyframes toast-pop {
  0%   { opacity: 0; transform: translate(-50%, -24px) scale(0.92); }
  100% { opacity: 1; transform: translate(-50%, 0)     scale(1); }
}

.req { color: #ef4444; }

.empty {
  color: #6b7280;
  font-style: italic;
}

.muted { color: #6b7280; }
.muted.small { font-size: 0.8rem; margin-top: -0.5rem; margin-bottom: 1rem; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login {
  width: 100%;
  max-width: 380px;
}

.login h1 { margin-top: 0; }

.user-strip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #d1d5db;
  margin-left: auto;   /* push user + logout to the right */
}

.logout-btn {
  background: transparent;
  color: white;
  border: 1px solid #4b5563;
}

.role-badge {
  display: inline-block;
  background: #3b82f6;
  color: white;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

button[disabled] { opacity: 0.5; cursor: not-allowed; }

.row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.pending-photos {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.pending-photos li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f3f4f6;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
}

.link-btn {
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-size: 1rem;
  color: #6b7280;
}
.link-btn:hover { color: #1f2937; background: transparent; }
.danger-text { color: #991b1b; }
.danger-text:hover { color: #7f1d1d; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  background: white;
  border-radius: 8px;
  width: min(900px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 { margin: 0; font-size: 1rem; }

.modal-header button {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #6b7280;
  margin: 0;
  padding: 0.25rem 0.5rem;
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
}

.photo-grid figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
  background: #f9fafb;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.photo-grid figcaption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  color: #4b5563;
}

.photo-grid figcaption span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------- Mobile ---------------- */
@media (max-width: 640px) {
  /* Tighter outer chrome */
  main { padding: 1rem; }
  header { padding: 0.5rem 0.75rem; }

  /* Header stays one row — slim and dense */
  .header-top {
    gap: 0.5rem;
    margin-bottom: 0.4rem;
  }
  .flag-btn { width: 26px; height: 18px; }
  .user-strip { font-size: 0.8rem; min-width: 0; }
  .user-strip .role-badge { display: none; }   /* hide role text on phone; current-user name is enough */

  /* Logout collapses to an icon */
  .logout-text { display: none; }
  .logout-icon { display: inline-block; }
  .logout-btn { padding: 0.4rem 0.55rem; }

  /* Nav becomes a horizontal scroll strip — every tab stays reachable */
  nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -1rem;
    padding: 0 1rem 0.25rem;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  nav button {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* Cards: thinner padding so forms get more usable space */
  .card { padding: 1rem; }

  /* Form rows already wrap via min-width; just tighten gaps */
  .row { gap: 0.5rem; margin-bottom: 0.5rem; }
  label { margin-bottom: 0.75rem; }

  /* 16px font on inputs prevents iOS Safari auto-zoom on focus */
  input, select, textarea { font-size: 16px; }

  /* Slightly larger touch targets */
  button { padding: 0.55rem 0.85rem; min-height: 40px; }
  /* …except small inline link buttons */
  .link-btn, .flag-btn, .modal-header button { min-height: 0; padding: 0; }

  /* Generic tables (Projects, Users) become horizontally scrollable */
  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    box-shadow: none;
    border: 1px solid #e5e7eb;
  }
  th, td { padding: 0.5rem 0.75rem; }

  /* Card-per-row layout shared by Time Entries / Projects / Users on mobile.
     The entries-specific extras (hours pill, description block) live below. */
  .card-table {
    display: block;
    background: transparent;
    border: none;
    box-shadow: none;
    overflow: visible;
    white-space: normal;
  }
  .card-table thead { display: none; }
  .card-table tbody,
  .card-table tbody tr,
  .card-table tbody td { display: block; }

  .card-table tbody tr {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    position: relative;
  }

  .card-table tbody td {
    border: none;
    padding: 0.15rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
  }

  .card-table tbody td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: #6b7280;
    margin-right: 0.35rem;
  }

  /* Hide cells that have no value (e.g. project with no number/email/address) */
  .card-table tbody td[data-label]:empty { display: none; }

  /* Actions row: equal-width buttons, separated by a thin divider */
  .card-table tbody td.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px solid #f3f4f6;
  }
  .card-table tbody td.row-actions::before { content: none; }
  .card-table tbody td.row-actions button {
    flex: 1 1 auto;
    margin: 0;
  }

  /* Totals row (only Time Entries actually has one): one-line summary on the right */
  .card-table tfoot { display: block; }
  .card-table tfoot tr {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    background: #f9fafb;
    border-radius: 8px;
    padding: 0.6rem 1rem;
  }
  .card-table tfoot td {
    display: inline-block;
    padding: 0;
    border: none;
    background: transparent;
  }
  .card-table tfoot td::before { content: none; }
  .card-table tfoot td:empty { display: none; }

  /* ---- Entries-only extras ---- */

  /* Hours as a pill in the top-right of the card */
  .entries-table tbody td.hours-cell {
    position: absolute;
    top: 0.55rem;
    right: 0.9rem;
    background: #eef2ff;
    color: #1e3a8a;
    padding: 0.15rem 0.7rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
  }
  .entries-table tbody td.hours-cell::before { display: none; }
  .entries-table tbody td.hours-cell::after {
    content: " h";
    font-weight: 400;
    opacity: 0.75;
  }
  /* Give Date a bit of right padding so it doesn't run under the hours pill */
  .entries-table tbody tr > td:first-child { padding-right: 4.5rem; }

  /* Description gets its own paragraph block below the label */
  .entries-table tbody td.description-cell { margin-top: 0.25rem; }
  .entries-table tbody td.description-cell::before { display: block; margin-bottom: 0.1rem; }

  /* Filters: each filter takes a full row on phone */
  .filters { gap: 0.5rem; }
  .filters label { flex: 1 1 100%; min-width: 0; }

  /* Export bar stays one line but more breathable */
  .export-bar { flex-wrap: wrap; gap: 0.5rem; }

  /* Photo grid: smaller minimum so two photos fit even on narrow phones */
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.5rem;
  }

  /* Modal: take more of the screen */
  .modal-backdrop { padding: 0.5rem; }
  .modal { max-height: 95vh; }

  /* Login screen: stop fighting the keyboard */
  .login-wrap { padding: 1rem; min-height: 100dvh; align-items: flex-start; padding-top: 3rem; }

  /* Toast: a touch smaller so it doesn't hog the screen on a phone */
  .alert { font-size: 0.875rem; padding: 0.6rem 1rem; max-width: 95vw; }
}
