/* LPV Productions — Crew Scheduling */

:root {
  --primary:   #212529;
  --success:   #198754;
  --danger:    #dc3545;
  --warning:   #ffc107;
  --pending:   #0d6efd;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f8f9fa;
  color: #212529;
  min-height: 100vh;
}

/* ─── Layout ─────────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

/* ─── Topbar / Navbar ─────────────────────────────────────── */
.topbar {
  background: #212529;
  border-bottom: 1px solid #343a40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 58px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
  text-decoration: none;
}

.topbar-brand span { color: #fff; font-weight: 800; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .875rem;
  color: #adb5bd;
}

/* ─── Tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #dee2e6;
  margin-bottom: 1.5rem;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: #6c757d;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  padding: .65rem 1.1rem;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover { color: #212529; }
.tab-btn.active { color: #212529; border-bottom-color: #212529; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .125);
  border-radius: .5rem;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .07);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: .75rem;
}

.card-title { font-size: 1rem; font-weight: 600; color: #212529; }

.card-meta { font-size: .8rem; color: #6c757d; margin-top: .2rem; }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .44rem 1rem;
  border-radius: .375rem;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.5;
  transition: color .15s, background-color .15s, border-color .15s;
}

.btn:disabled { opacity: .65; cursor: not-allowed; }

.btn-primary   { background: #212529; color: #fff; border-color: #212529; }
.btn-primary:hover:not(:disabled) { background: #343a40; border-color: #343a40; }

.btn-secondary { background: #6c757d; color: #fff; border-color: #6c757d; }
.btn-secondary:hover:not(:disabled) { background: #5c636a; border-color: #5c636a; }

.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #bb2d3b; }

.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: #157347; }

.btn-sm { padding: .3rem .65rem; font-size: .8rem; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

label {
  display: block;
  font-size: .875rem;
  color: #495057;
  font-weight: 500;
  margin-bottom: .35rem;
}

input, select, textarea {
  width: 100%;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: .375rem;
  color: #212529;
  padding: .5rem .75rem;
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #6c757d;
  box-shadow: 0 0 0 .2rem rgba(33, 37, 41, .1);
}

input[readonly] { background: #e9ecef; cursor: not-allowed; }

textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .28rem .6rem;
  border-radius: .375rem;
  font-size: .74rem;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-pending   { background: #cfe2ff; color: #084298; }
.badge-confirmed { background: #d1e7dd; color: #0a3622; }
.badge-declined  { background: #f8d7da; color: #58151c; }
.badge-open      { background: #fff3cd; color: #664d03; }
.badge-draft     { background: #e2e3e5; color: #41464b; }
.badge-completed { background: #d1e7dd; color: #0a3622; }
.badge-cancelled { background: #f8d7da; color: #58151c; }
.badge-admin     { background: #fde8e6; color: #7d1a11; }
.badge-crew      { background: #cfe2ff; color: #084298; }

/* ─── Tables ─────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: .5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .07);
  margin-bottom: 1rem;
}

table { width: 100%; border-collapse: collapse; font-size: .875rem; }

th {
  text-align: left;
  padding: .7rem .85rem;
  color: #495057;
  border-bottom: 2px solid #dee2e6;
  font-weight: 600;
  white-space: nowrap;
  background: #f8f9fa;
}

td {
  padding: .65rem .85rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
  color: #212529;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fa; }

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .175);
  border-radius: .5rem;
  width: 100%;
  max-width: 540px;
  padding: 1.5rem;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
}

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

.modal-title { font-size: 1.1rem; font-weight: 600; color: #212529; }

.modal-close {
  background: none;
  border: none;
  color: #6c757d;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: .25rem;
}

.modal-close:hover { color: #212529; }

.modal-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
  padding-top: .85rem;
  border-top: 1px solid #dee2e6;
}

/* ─── Calendar ───────────────────────────────────────────── */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-day-header {
  text-align: center;
  font-size: .75rem;
  color: #6c757d;
  font-weight: 600;
  padding: .3rem;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: .375rem;
  cursor: pointer;
  font-size: .85rem;
  border: 1px solid transparent;
  transition: background .15s;
  position: relative;
  min-height: 42px;
  background: #fff;
}

.cal-day:hover { border-color: #495057; background: #f8f9fa; }
.cal-day.empty { cursor: default; background: transparent; }
.cal-day.today { border-color: #adb5bd; background: #e9ecef; }
.cal-day.available   { background: #d1e7dd; }
.cal-day.unavailable { background: #f8d7da; }
.cal-day.has-crew    { background: #cfe2ff; }

.cal-day-num { font-weight: 600; }
.cal-day-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--success); margin-top: 2px; }

/* ─── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: .375rem;
  margin-bottom: 1rem;
  font-size: .875rem;
}

.alert-error   { background: #f8d7da; border: 1px solid #f5c2c7; color: #842029; }
.alert-success { background: #d1e7dd; border: 1px solid #badbcc; color: #0f5132; }

/* ─── Login Page ─────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  padding: 1rem;
}

.login-box {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .125);
  border-radius: .5rem;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .1);
}

.login-logo { text-align: center; margin-bottom: 1.5rem; }

.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: #212529; }
.login-logo h1 span { color: #212529; }
.login-logo p { color: #6c757d; font-size: .875rem; margin-top: .25rem; }

/* ─── Utilities ──────────────────────────────────────────── */
.hidden       { display: none !important; }
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: .5rem; }
.gap-3        { gap: .75rem; }
.mb-1         { margin-bottom: .25rem; }
.mb-3         { margin-bottom: .75rem; }
.mb-4         { margin-bottom: 1rem; }
.text-muted   { color: #6c757d; font-size: .875rem; }
.text-sm      { font-size: .85rem; }
.text-right   { text-align: right; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-title { font-size: 1.1rem; font-weight: 600; color: #212529; }

.empty-state {
  text-align: center;
  color: #6c757d;
  padding: 2.5rem 1rem;
  font-size: .9rem;
}

/* ─── Item Cards (Jobs / Crew / Assignments lists) ───────── */
.item-card {
  background: #fff;
  border: 1px solid rgba(0, 0, 0, .1);
  border-radius: .5rem;
  padding: .875rem 1rem;
  margin-bottom: .5rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  transition: box-shadow .15s;
}

.item-card:hover { box-shadow: 0 2px 6px rgba(0, 0, 0, .1); }

.item-card-main { flex: 1; min-width: 0; }

.item-card-title {
  font-weight: 600;
  font-size: .95rem;
  color: #212529;
  margin-bottom: .2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-card-meta { font-size: .8rem; color: #6c757d; margin-top: .2rem; }

.item-card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .4rem;
}

.item-card-actions {
  display: flex;
  gap: .4rem;
  align-items: flex-start;
  flex-shrink: 0;
}

/* ─── Responsive / Mobile ────────────────────────────────── */
@media (max-width: 768px) {
  .main-content { padding: 1rem .75rem; }

  .tabs {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { flex-shrink: 0; }

  .modal { padding: 1.25rem 1rem; }
  .modal-actions { flex-direction: column-reverse; gap: .5rem; }
  .modal-actions .btn { width: 100%; justify-content: center; }
}

@media (max-width: 600px) {
  .form-row { grid-template-columns: 1fr; }
  .topbar-user span.user-name { display: none; }
  .topbar { padding: 0 1rem; }
  input, select, textarea { font-size: 1rem; }
  .btn-sm { padding: .4rem .8rem; }
  .section-header { flex-wrap: wrap; gap: .5rem; }
  .card-header { flex-wrap: wrap; gap: .5rem; }
  .col-hide-sm { display: none; }
  .login-box { padding: 1.75rem 1.25rem; }
}

/* iOS safe-area support */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .app-shell { padding-bottom: env(safe-area-inset-bottom); }
}
