/* ============================================================
   Planning Estate - Clean Masterzz
   ============================================================ */

:root {
  --primary:        #1565C0;
  --primary-light:  #1976D2;
  --primary-dark:   #0D47A1;
  --primary-bg:     #E3F2FD;
  --success:        #2E7D32;
  --success-bg:     #E8F5E9;
  --warning:        #E65100;
  --warning-bg:     #FFF3E0;
  --danger:         #C62828;
  --danger-bg:      #FFEBEE;
  --bg:             #F5F7FA;
  --surface:        #FFFFFF;
  --surface-hover:  #F8F9FB;
  --text:           #212121;
  --text-muted:     #757575;
  --border:         #E0E0E0;
  --radius:         8px;
  --shadow:         0 2px 8px rgba(0,0,0,.10);
  --shadow-md:      0 4px 16px rgba(0,0,0,.14);
}

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

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3 { line-height: 1.3; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.9); }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.9); }

.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-bg); }

.btn-ghost     { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--surface-hover); }

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

/* ============================================================
   FORMS
   ============================================================ */
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
label { font-size: .875rem; font-weight: 500; color: var(--text); }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  padding: .55rem .8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,101,192,.15);
}
textarea { resize: vertical; min-height: 80px; }

/* ============================================================
   ALERTS & BADGES
   ============================================================ */
.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
}
.alert-error   { background: var(--danger-bg); color: var(--danger); border-left: 3px solid var(--danger); }
.alert-success { background: var(--success-bg); color: var(--success); border-left: 3px solid var(--success); }

.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .65rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-gepland     { background: var(--primary-bg); color: var(--primary); }
.badge-klaar       { background: var(--success-bg); color: var(--success); }
.badge-geannuleerd { background: var(--danger-bg);  color: var(--danger);  }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .logo-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: .5rem;
}
.login-logo h1 {
  color: var(--primary);
  font-size: 1.4rem;
}
.login-logo p {
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: .25rem;
}
.login-card .btn-primary {
  width: 100%;
  justify-content: center;
  padding: .7rem;
  font-size: 1rem;
  margin-top: .5rem;
}
#login-error { display: none; }

/* ============================================================
   DASHBOARD LAYOUT
   ============================================================ */
.app-header {
  background: var(--primary);
  color: #fff;
  padding: .85rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header .header-logo { font-size: 1.25rem; font-weight: 700; flex: 1; }
.app-header .header-user { font-size: .875rem; opacity: .9; }
.app-header .btn-ghost {
  color: #fff;
  border-color: rgba(255,255,255,.4);
  padding: .35rem .75rem;
  font-size: .8rem;
}
.app-header .btn-ghost:hover { background: rgba(255,255,255,.15); }

.app-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ============================================================
   TABS
   ============================================================ */
.tabs {
  display: flex;
  gap: .25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab-btn {
  padding: .65rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -2px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

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

/* ============================================================
   SECTION HEADERS
   ============================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: .75rem;
}
.section-header h2 { font-size: 1.15rem; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .875rem;
}
thead th {
  padding: .75rem 1rem;
  text-align: left;
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
.td-actions { display: flex; gap: .4rem; align-items: center; }
.td-notes { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: .8rem; }

/* ============================================================
   PLANNING VIEW
   ============================================================ */
.planning-day {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}
.planning-day-header {
  background: var(--primary-bg);
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.planning-day-header .day-label {
  font-weight: 600;
  color: var(--primary);
  font-size: .95rem;
}
.planning-day-header .day-count {
  font-size: .8rem;
  color: var(--text-muted);
}
.planning-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.planning-item:last-child { border-bottom: none; }
.planning-item .pi-address { flex: 1; min-width: 160px; font-weight: 500; }
.planning-item .pi-meta { color: var(--text-muted); font-size: .8rem; }
.planning-item .pi-actions { display: flex; gap: .4rem; margin-left: auto; }
.planning-item .pi-notes {
  width: 100%;
  font-size: .8rem;
  color: var(--text-muted);
  padding-top: .25rem;
}
.planning-empty {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: .9rem;
}

/* ============================================================
   MONTH NAVIGATION
   ============================================================ */
.month-nav {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.month-nav .month-label {
  font-weight: 600;
  font-size: 1rem;
  min-width: 130px;
  text-align: center;
}

/* ============================================================
   COMMENTS
   ============================================================ */
.comments-selector {
  margin-bottom: 1.25rem;
}
.comments-selector select { max-width: 350px; }

.comment-thread {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.comment-item {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: .75rem;
}
.comment-item:last-child { border-bottom: none; }
.comment-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}
.comment-body { flex: 1; }
.comment-meta {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  margin-bottom: .2rem;
}
.comment-author { font-weight: 600; font-size: .875rem; }
.comment-date   { font-size: .75rem; color: var(--text-muted); }
.comment-text   { font-size: .875rem; }
.comment-delete { margin-left: auto; align-self: flex-start; flex-shrink: 0; }
.comment-no-address {
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
}
.comment-form {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  margin-top: .75rem;
  display: flex;
  gap: .75rem;
  align-items: flex-end;
}
.comment-form textarea { flex: 1; margin-bottom: 0; }
.comment-form .btn { flex-shrink: 0; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .18s ease;
}
@keyframes modalIn {
  from { transform: translateY(-16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 0 .25rem;
}
.modal-close:hover { color: var(--text); }
.modal-body   { padding: 1.5rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
  padding: 2.5rem;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .app-header { padding: .75rem 1rem; }
  .app-main   { padding: 1rem .75rem; }
  .planning-item .pi-actions { margin-left: 0; }
  .modal { max-width: 100%; }
  thead th:nth-child(n+4),
  tbody td:nth-child(n+4) { display: none; }
}

@media (max-width: 480px) {
  .login-card { padding: 2rem 1.25rem; }
  .tab-btn    { padding: .55rem .85rem; font-size: .82rem; }
}
