/* ============================================================
   CREW PORTAL - Styling
   Royal Blue + Gold nautical theme
============================================================ */

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

:root {
  --royal: #1e3a8a;
  --royal-light: #3b82f6;
  --royal-dark: #0c1a4d;
  --gold: #d4af37;
  --gold-soft: #e8d28e;
  --gold-dim: #b08d1f;
  --bg: #030712;
  --bg-card: #0f172a;
  --bg-elevated: #1e293b;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: rgba(59, 130, 246, 0.2);
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(180deg, var(--royal-dark) 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body.app { padding-bottom: calc(env(safe-area-inset-bottom) + 80px); }

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-soft); }

/* ============ HEADER ============ */
.app-header {
  background: linear-gradient(135deg, var(--royal-dark), rgba(30, 58, 138, 0.7));
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(212, 175, 55, 0.3);
  position: sticky; top: 0;
  backdrop-filter: blur(10px);
  z-index: 100;
}
.app-header .top-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.app-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  color: white;
  font-weight: 500;
  line-height: 1;
}
.app-subtitle {
  font-size: 0.7rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 0.2rem;
}
.user-menu {
  display: flex; align-items: center; gap: 0.6rem;
  font-size: 0.85rem;
}
.user-menu a.logout {
  color: var(--text-muted);
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.75rem;
}
.user-menu a.logout:hover { color: var(--danger); border-color: var(--danger); }

/* ============ NAV TABS ============ */
.nav-tabs {
  display: flex; gap: 0.25rem;
  overflow-x: auto;
  padding: 0.25rem 0;
  margin-top: 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs a {
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 8px;
  white-space: nowrap;
  transition: all 0.2s;
}
.nav-tabs a:hover { color: var(--text); }
.nav-tabs a.active {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold);
  border: 1px solid rgba(212, 175, 55, 0.3);
}

/* ============ VIEW SWITCH (crew/admin) ============ */
.view-switch {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  margin-right: 0.5rem;
}
.view-switch a {
  padding: 0.25rem 0.7rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-radius: 6px;
}
.view-switch a.active { background: var(--royal); color: white; }

/* ============ CONTAINER ============ */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
}
.container-wide { max-width: 1100px; }

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.4rem;
  color: white;
  font-weight: 500;
}
.card-sub {
  font-size: 0.75rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.25rem;
}

/* ============ FORMS ============ */
label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold-soft);
  margin-bottom: 0.4rem;
  margin-top: 0.75rem;
}
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="number"], input[type="date"], input[type="time"], input[type="url"],
select, textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: white;
  font-size: 1rem;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}
textarea { min-height: 100px; resize: vertical; }
input[type="file"] {
  padding: 0.5rem;
  background: var(--bg-elevated);
  border: 1px dashed var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  width: 100%;
  font-family: inherit;
}
input[type="checkbox"], input[type="radio"] {
  width: 1.1rem; height: 1.1rem;
  accent-color: var(--gold);
  margin-right: 0.4rem;
}
.checkbox-label {
  display: flex; align-items: center;
  font-size: 0.9rem;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  font-weight: normal;
  margin: 0.4rem 0;
}

/* ============ BUTTONS ============ */
.btn, button {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(135deg, var(--royal), var(--royal-light));
  color: white;
  border: 0;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: all 0.2s;
}
.btn:hover, button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(30, 58, 138, 0.3);
  color: white;
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold-dim), var(--gold));
  color: var(--royal-dark);
}
.btn-gold:hover { color: var(--royal-dark); }
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { color: white; box-shadow: none; transform: none; }
.btn-danger { background: var(--danger); }
.btn-success { background: var(--success); }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.75rem; }
.btn-full { width: 100%; }
.btn-row {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin-top: 1rem;
}

/* ============ MESSAGES ============ */
.flash {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.flash.success {
  background: rgba(16, 185, 129, 0.15);
  border-left: 4px solid var(--success);
  color: #a7f3d0;
}
.flash.error {
  background: rgba(239, 68, 68, 0.15);
  border-left: 4px solid var(--danger);
  color: #fca5a5;
}
.flash.info {
  background: rgba(59, 130, 246, 0.15);
  border-left: 4px solid var(--royal-light);
  color: #bfdbfe;
}

/* ============ LISTS & TABLES ============ */
.list-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  display: flex; align-items: center; gap: 1rem;
}
.list-item-main { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; color: white; }
.list-item-sub { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }
.list-item-actions { display: flex; gap: 0.4rem; }

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.data th, table.data td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data th {
  color: var(--gold);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
table.data tr:hover { background: rgba(59, 130, 246, 0.05); }

/* ============ BADGES ============ */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge.pending { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge.approved { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.badge.paid { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.badge.rejected { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.badge.open { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.badge.aan_boord { background: rgba(16, 185, 129, 0.25); color: #6ee7b7; }
.badge.vrij { background: rgba(148, 163, 184, 0.25); color: #cbd5e1; }
.badge.verlof { background: rgba(245, 158, 11, 0.25); color: #fcd34d; }
.badge.high { background: var(--danger); color: white; }
.badge.normal { background: var(--royal-light); color: white; }

/* ============ DASHBOARD ============ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  transition: all 0.2s;
}
.dash-card.clickable { cursor: pointer; }
.dash-card.clickable:hover { border-color: var(--gold); transform: translateY(-2px); }
.dash-card-icon { font-size: 1.75rem; margin-bottom: 0.25rem; }
.dash-card-num {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gold);
  font-family: 'Cormorant Garamond', serif;
}
.dash-card-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* ============ SECTIONS ============ */
.section-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  color: white;
  margin: 1.5rem 0 0.75rem;
  font-weight: 500;
}
.section-sub {
  font-size: 0.75rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-bottom: 0.75rem;
}

/* ============ SCHEDULE GRID ============ */
.schedule-grid {
  overflow-x: auto;
  margin: 1rem -1rem;
  padding: 0 1rem;
  -webkit-overflow-scrolling: touch;
}
.schedule-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
}
.schedule-table th {
  font-size: 0.7rem;
  color: var(--gold);
  padding: 0.5rem 0.3rem;
  text-align: center;
  text-transform: uppercase;
}
.schedule-table td {
  padding: 0.3rem;
  text-align: center;
}
.schedule-table td.crew {
  text-align: left;
  color: white;
  font-size: 0.85rem;
  padding-right: 0.5rem;
  white-space: nowrap;
}
.day-cell {
  width: 60px; height: 40px;
  border-radius: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}
.day-cell.aan_boord { background: rgba(16, 185, 129, 0.35); color: white; border-color: var(--success); }
.day-cell.vrij { background: rgba(148, 163, 184, 0.25); color: white; }
.day-cell.verlof { background: rgba(245, 158, 11, 0.35); color: white; border-color: var(--warning); }
.day-cell:hover { transform: scale(1.05); }

/* ============ MODAL ============ */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; z-index: 200;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

/* ============ PHOTO UPLOAD ============ */
.photo-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.photo-preview img {
  width: 100%; height: 100px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ============ AVATAR ============ */
.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--royal), var(--royal-light));
  display: inline-flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.avatar-lg { width: 72px; height: 72px; font-size: 1.4rem; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* ============ HELPERS ============ */
.text-muted { color: var(--text-muted); }
.text-gold { color: var(--gold); }
.text-small { font-size: 0.85rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.w-full { width: 100%; }

/* ============ RESPONSIVE ============ */
@media (max-width: 600px) {
  .container { padding: 0.75rem; }
  .card { padding: 1rem; }
  .app-header { padding: 0.75rem 0.75rem 0.5rem; }
  .app-title { font-size: 1.25rem; }
  h1 { font-size: 1.5rem; }
  .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============ LOGIN SPECIFIC ============ */
.login-page {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 2rem 1.5rem;
}
.login-title {
  text-align: center;
  margin-bottom: 2rem;
}
.login-title h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.5rem;
  color: white;
  font-weight: 500;
}
.login-title .sub {
  color: var(--gold);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-top: 0.5rem;
}
.login-title .divider {
  display: flex; align-items: center; gap: 0.6rem;
  justify-content: center;
  margin: 0.5rem 0;
  color: var(--gold);
}
.login-title .divider::before, .login-title .divider::after {
  content: ''; height: 1px; background: var(--gold); width: 40px;
}
.login-form {
  background: rgba(30, 58, 138, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: 16px;
  padding: 2rem;
  max-width: 400px;
  width: 100%;
}
.login-form button { width: 100%; }
