/* public/css/app.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface2: #f0efeb;
  --border: rgba(0,0,0,0.10);
  --border-md: rgba(0,0,0,0.18);
  --text: #1a1a18;
  --text2: #5f5e5a;
  --text3: #9e9d98;
  --blue: #185FA5;
  --blue-bg: #E6F1FB;
  --blue-text: #0C447C;
  --green: #1D9E75;
  --green-bg: #EAF3DE;
  --green-text: #27500A;
  --amber-bg: #FAEEDA;
  --amber-text: #633806;
  --red: #E24B4A;
  --red-bg: #FCEBEB;
  --red-text: #791F1F;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0;
  background: var(--surface);
  border-right: 0.5px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  overflow-y: auto;
}
.main-content { margin-left: 220px; flex: 1; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 0.5px solid var(--border);
  padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.page-content { padding: 24px; max-width: 1100px; }

/* Sidebar */
.sb-header { padding: 16px; border-bottom: 0.5px solid var(--border); }
.sb-logo { font-weight: 600; font-size: 15px; color: var(--text); margin-bottom: 8px; }
.sb-user-name { font-weight: 500; font-size: 13px; }
.nav-section { font-size: 10px; color: var(--text3); padding: 10px 16px 3px; letter-spacing: .07em; text-transform: uppercase; }
.nav-item {
  padding: 9px 16px; font-size: 13px; cursor: pointer;
  color: var(--text2); border-left: 2px solid transparent;
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; transition: background .1s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--bg); color: var(--text); border-left-color: var(--blue); font-weight: 500; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.sb-footer { margin-top: auto; padding: 14px 16px; border-top: 0.5px solid var(--border); }

/* Cards */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 16px;
}
.card-title { font-size: 13px; font-weight: 500; margin-bottom: 14px; }

/* Metrics */
.metrics-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--surface2); border-radius: var(--radius); padding: 14px 16px; }
.metric-label { font-size: 11px; color: var(--text3); margin-bottom: 4px; }
.metric-value { font-size: 24px; font-weight: 600; line-height: 1; }

/* Badges */
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 500; }
.badge-green { background: var(--green-bg); color: var(--green-text); }
.badge-blue  { background: var(--blue-bg);  color: var(--blue-text); }
.badge-amber { background: var(--amber-bg); color: var(--amber-text); }
.badge-red   { background: var(--red-bg);   color: var(--red-text); }
.badge-gray  { background: var(--surface2); color: var(--text2); }

/* Role badges */
.rb { font-size: 11px; padding: 2px 9px; border-radius: 20px; font-weight: 500; display: inline-block; }
.rb-admin  { background: var(--blue-bg);  color: var(--blue-text); }
.rb-staff  { background: var(--green-bg); color: var(--green-text); }
.rb-client { background: var(--amber-bg); color: var(--amber-text); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 8px 10px; font-weight: 500; color: var(--text3); border-bottom: 0.5px solid var(--border); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 10px 10px; border-bottom: 0.5px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* Buttons */
.btn {
  padding: 7px 14px; font-size: 13px; border-radius: var(--radius);
  cursor: pointer; border: 0.5px solid var(--border-md);
  background: transparent; color: var(--text); font-weight: 400;
  transition: background .1s; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px;
}
.btn:hover { background: var(--bg); }
.btn:active { opacity: .85; }
.btn-primary { background: var(--blue); color: #fff; border: none; font-weight: 500; }
.btn-primary:hover { background: var(--blue-text); }
.btn-danger { border-color: var(--red); color: var(--red-text); }
.btn-danger:hover { background: var(--red-bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* Forms */
.form-row { display: grid; gap: 12px; margin-bottom: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text2); font-weight: 400; }
.field input, .field select, .field textarea {
  padding: 8px 10px; font-size: 13px;
  border: 0.5px solid var(--border-md); border-radius: var(--radius);
  background: var(--bg); color: var(--text); outline: none;
  transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue); box-shadow: 0 0 0 2px rgba(24,95,165,0.1);
}
.field textarea { min-height: 80px; resize: vertical; line-height: 1.6; }
.field-hint { font-size: 11px; color: var(--text3); }

/* Toggle */
.toggle { width: 34px; height: 18px; border-radius: 9px; background: var(--surface2); border: 0.5px solid var(--border-md); cursor: pointer; position: relative; transition: .15s; flex-shrink: 0; }
.toggle.on { background: var(--green); border-color: #0F6E56; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: .15s; }
.toggle.on::after { left: 18px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 0.5px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }

/* Avatar */
.avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.av-blue   { background: var(--blue-bg);  color: var(--blue-text); }
.av-green  { background: var(--green-bg); color: var(--green-text); }
.av-amber  { background: var(--amber-bg); color: var(--amber-text); }

/* User row */
.user-cell { display: flex; align-items: center; gap: 8px; }

/* Alerts */
.alert { padding: 12px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 12px; }
.alert-success { background: var(--green-bg); color: var(--green-text); border-left: 3px solid var(--green); border-radius: 0 var(--radius) var(--radius) 0; }
.alert-error   { background: var(--red-bg);   color: var(--red-text);   border-left: 3px solid var(--red);   border-radius: 0 var(--radius) var(--radius) 0; }
.alert-info    { background: var(--blue-bg);  color: var(--blue-text);  border-left: 3px solid var(--blue);  border-radius: 0 var(--radius) var(--radius) 0; }

/* Modal overlay */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 24px; width: 100%; max-width: 500px;
  border: 0.5px solid var(--border); max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 16px; font-weight: 500; margin-bottom: 18px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* QR Box */
.qr-container { display: flex; gap: 20px; align-items: flex-start; }
.qr-image { width: 140px; height: 140px; border: 0.5px solid var(--border); border-radius: var(--radius); object-fit: contain; background: #fff; flex-shrink: 0; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
}

/* Page title */
.page-title { font-size: 18px; font-weight: 600; }
.page-subtitle { font-size: 13px; color: var(--text2); }

/* Chips */
.chip { display: inline-flex; align-items: center; gap: 3px; background: var(--blue-bg); color: var(--blue-text); border-radius: 20px; font-size: 11px; padding: 2px 8px; margin: 1px; font-weight: 500; }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text3); font-size: 13px; }

/* Preview box */
.preview-box { background: var(--bg); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 12px 14px; font-size: 13px; line-height: 1.7; white-space: pre-wrap; min-height: 60px; border-left: 3px solid var(--blue); border-radius: 0 var(--radius) var(--radius) 0; }

/* Var chips */
.var-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.var-chip { font-size: 11px; padding: 2px 8px; border-radius: 20px; border: 0.5px solid var(--border-md); color: var(--text2); cursor: pointer; background: var(--surface); }
.var-chip:hover { background: var(--bg); color: var(--text); }
