/* assets/css/app.css – SkyLog */

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

:root {
  --sidebar-w: 220px;
  --color-primary: #185FA5;
  --color-primary-dark: #0C447C;
  --color-primary-light: #E6F1FB;
  --color-bg: #F5F6F8;
  --color-surface: #FFFFFF;
  --color-border: rgba(0,0,0,.1);
  --color-border-md: rgba(0,0,0,.18);
  --color-text: #1A1A1A;
  --color-text-muted: #5F5E5A;
  --color-text-faint: #888780;
  --color-success-bg: #EAF3DE;
  --color-success-text: #27500A;
  --color-warning-bg: #FAEEDA;
  --color-warning-text: #633806;
  --color-danger-bg: #FCEBEB;
  --color-danger-text: #A32D2D;
  --color-info-bg: #E6F1FB;
  --color-info-text: #0C447C;
  --radius: 8px;
  --radius-lg: 12px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body { background: var(--color-bg); color: var(--color-text); font-size: 14px; line-height: 1.5; }

/* ── Shell ── */
.app-shell { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--color-surface);
  border-right: 0.5px solid var(--color-border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 0.5px solid var(--color-border);
}
.logo-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo-text { font-size: 15px; font-weight: 600; }
.logo-sub  { font-size: 10px; color: var(--color-text-muted); }

.sidebar-nav { flex: 1; padding: 12px 8px; }
.nav-section-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .07em; color: var(--color-text-faint);
  padding: 0 10px; margin: 0 0 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--radius);
  font-size: 13px; color: var(--color-text-muted);
  text-decoration: none; transition: background .1s, color .1s;
  margin-bottom: 2px;
}
.nav-item:hover  { background: var(--color-bg); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-light); color: var(--color-primary); font-weight: 500; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer { border-top: 0.5px solid var(--color-border); padding: 10px 12px; }
.user-pill { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--color-text-muted); }
.logout-btn { margin-left: auto; color: var(--color-text-faint); }
.logout-btn:hover { color: var(--color-danger-text); }

/* ── Main ── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ── Page header ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 28px 0;
}
.page-title { font-size: 20px; font-weight: 600; }
.page-sub   { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; }

/* ── Content area ── */
.page-body { padding: 20px 28px 40px; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  border: 0.5px solid var(--color-border-md);
  background: transparent; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--color-text);
  font-family: inherit; text-decoration: none; transition: background .1s;
}
.btn:hover   { background: var(--color-bg); }
.btn-primary { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-danger  { background: var(--color-danger-bg); color: var(--color-danger-text); border-color: #F7C1C1; }
.btn-sm      { padding: 4px 10px; font-size: 12px; }

/* ── Stats row ── */
.stats-row { display: grid; grid-template-columns: repeat(5,1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--color-surface); border: 0.5px solid var(--color-border); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-label { font-size: 11px; color: var(--color-text-muted); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 600; }
.stat-sub   { font-size: 11px; color: var(--color-text-faint); margin-top: 2px; }

/* ── Alerts ── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-info    { background: var(--color-info-bg);    color: var(--color-info-text); }
.alert-success { background: var(--color-success-bg); color: var(--color-success-text); }
.alert-danger  { background: var(--color-danger-bg);  color: var(--color-danger-text); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning-text); }

/* ── Table card ── */
.table-card { background: var(--color-surface); border: 0.5px solid var(--color-border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 24px; }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 0.5px solid var(--color-border); }
.table-count { font-size: 13px; color: var(--color-text-muted); }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  padding: 8px 10px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; color: var(--color-text-muted);
  background: var(--color-bg);
  border-bottom: 0.5px solid var(--color-border);
}
tbody td { padding: 9px 10px; border-bottom: 0.5px solid var(--color-border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #F8F9FB; }

.reg  { font-family: monospace; font-weight: 600; font-size: 12px; }
.mono { font-family: monospace; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.badge-pic      { background: var(--color-info-bg);    color: var(--color-info-text); }
.badge-dual     { background: var(--color-success-bg); color: var(--color-success-text); }
.badge-training { background: var(--color-warning-bg); color: var(--color-warning-text); }

.editable-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.dot-open   { background: var(--color-primary); }
.dot-locked { background: var(--color-text-faint); }

/* ── Form sections ── */
.form-card { background: var(--color-surface); border: 0.5px solid var(--color-border); border-radius: var(--radius-lg); padding: 20px; margin-bottom: 16px; }
.form-card-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: var(--color-text-muted);
  margin-bottom: 14px; display: flex; align-items: center; gap: 6px;
}
.form-row { display: grid; gap: 12px; margin-bottom: 12px; }
.form-row:last-child { margin-bottom: 0; }
.r1 { grid-template-columns: 1fr; }
.r2 { grid-template-columns: 1fr 1fr; }
.r3 { grid-template-columns: 1fr 1fr 1fr; }
.r4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.r5 { grid-template-columns: 1fr 1fr 1fr 1fr 1fr; }
.r6 { grid-template-columns: repeat(6,1fr); }

.field label { display: block; font-size: 11px; font-weight: 600; color: var(--color-text-muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 7px 10px;
  border: 0.5px solid var(--color-border-md); border-radius: var(--radius);
  font-size: 13px; background: var(--color-surface); color: var(--color-text);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(24,95,165,.12);
}
.field input[readonly], .field input.readonly {
  background: var(--color-bg); color: var(--color-text-muted); cursor: default;
}
.field textarea { resize: vertical; min-height: 60px; line-height: 1.5; }
.field-hint { font-size: 11px; margin-top: 3px; display: flex; align-items: center; gap: 4px; }
.hint-ok   { color: var(--color-success-text); }
.hint-warn { color: var(--color-warning-text); }
.hint-err  { color: var(--color-danger-text); }

.aircraft-found-box {
  margin-top: 6px; padding: 8px 12px; border-radius: var(--radius);
  background: var(--color-info-bg); border: 0.5px solid #B5D4F4;
  font-size: 12px; color: var(--color-info-text);
  display: flex; align-items: center; gap: 8px;
}
.aircraft-not-found-box {
  margin-top: 6px; padding: 8px 12px; border-radius: var(--radius);
  background: var(--color-warning-bg); border: 0.5px solid #FAC775;
  font-size: 12px; color: var(--color-warning-text);
}
.aircraft-multi-box {
  margin-top: 6px; padding: 8px 12px; border-radius: var(--radius);
  background: var(--color-warning-bg); border: 0.5px solid #FAC775;
  font-size: 12px; color: var(--color-warning-text);
}

.char-count { font-size: 11px; color: var(--color-text-faint); text-align: right; margin-top: 3px; }

/* ── Guest tags ── */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; background: var(--color-bg);
  border: 0.5px solid var(--color-border-md); border-radius: 4px;
  font-size: 12px;
}
.tag-remove { color: var(--color-text-faint); cursor: pointer; font-size: 14px; line-height: 1; }
.tag-remove:hover { color: var(--color-danger-text); }

/* ── Audit log ── */
.audit-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.audit-table td { padding: 8px 10px; border-bottom: 0.5px solid var(--color-border); vertical-align: top; }
.audit-table tr:last-child td { border: none; }
.audit-time { color: var(--color-text-faint); white-space: nowrap; width: 150px; }
.audit-user { color: var(--color-primary); font-weight: 500; white-space: nowrap; width: 120px; }
.audit-action { color: var(--color-text-muted); }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--color-bg); }
.login-card { background: var(--color-surface); border: 0.5px solid var(--color-border); border-radius: var(--radius-lg); padding: 36px 32px; width: 360px; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-title { font-size: 22px; font-weight: 600; }
.login-sub   { font-size: 13px; color: var(--color-text-muted); margin-bottom: 24px; }

/* ── Search input ── */
.search-input { padding: 7px 10px; border: 0.5px solid var(--color-border-md); border-radius: var(--radius); font-size: 13px; background: var(--color-surface); color: var(--color-text); font-family: inherit; }

/* ── User search dropdown ── */
.user-dropdown {
  position:absolute; top:100%; left:0; right:0; z-index:100;
  background:var(--color-surface); border:0.5px solid var(--color-border-md);
  border-radius:var(--radius); box-shadow:0 4px 12px rgba(0,0,0,.08);
  max-height:220px; overflow-y:auto; margin-top:2px;
}
.user-dropdown-item {
  padding:8px 12px; cursor:pointer; font-size:13px;
  display:flex; align-items:center; justify-content:space-between;
  border-bottom:0.5px solid var(--color-border);
}
.user-dropdown-item:last-child { border-bottom:none; }
.user-dropdown-item:hover { background:var(--color-bg); }
.user-dropdown-item .fi-badge {
  font-size:10px; font-weight:600; padding:2px 6px; border-radius:3px;
  background:var(--color-warning-bg); color:var(--color-warning-text);
}
@media (max-width: 1100px) { .stats-row { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 860px)  { .r6 { grid-template-columns: repeat(3,1fr); } .r4 { grid-template-columns: 1fr 1fr; } }

/* ── Org switcher ── */
.org-switcher { position:relative; margin-bottom:4px; }
.org-switcher-btn {
  display:flex; align-items:center; gap:8px; width:100%;
  padding:7px 10px; border-radius:var(--radius); border:0.5px solid var(--color-border-md);
  background:var(--color-bg); cursor:pointer; font-family:inherit; font-size:13px;
  color:var(--color-text); transition:background .1s;
}
.org-switcher-btn:hover { background:var(--color-surface); }
.org-switcher-icon {
  width:24px; height:24px; border-radius:6px; background:var(--color-primary);
  display:flex; align-items:center; justify-content:center;
  font-size:10px; font-weight:600; color:#fff; flex-shrink:0;
}
.org-switcher-name { flex:1; text-align:left; font-weight:500; }
.org-switcher-menu {
  position:absolute; top:calc(100% + 4px); left:0; right:0; z-index:200;
  background:var(--color-surface); border:0.5px solid var(--color-border-md);
  border-radius:var(--radius-lg); overflow:hidden;
  box-shadow:0 4px 16px rgba(0,0,0,.1);
}
.org-menu-item {
  display:flex; align-items:center; gap:10px; padding:10px 12px;
  text-decoration:none; color:var(--color-text); font-size:13px;
  border-bottom:0.5px solid var(--color-border);
  transition:background .1s;
}
.org-menu-item:last-child { border-bottom:none; }
.org-menu-item:hover { background:var(--color-bg); }
.org-menu-item.active { background:var(--color-primary-light); }
.org-menu-icon {
  width:28px; height:28px; border-radius:7px; background:var(--color-primary);
  display:flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:600; color:#fff; flex-shrink:0;
}
.org-single-label {
  display:flex; align-items:center; gap:8px; padding:7px 10px;
  font-size:13px; color:var(--color-text-muted);
}
.org-single-label .org-switcher-icon { width:24px; height:24px; font-size:10px; }

/* ── SortableTable filter row ── */
.st-filter-row td {
  padding: 3px 6px 5px;
  background: var(--color-bg);
  border-bottom: 0.5px solid var(--color-border);
}
.st-filter-row td input:focus {
  outline: none;
  border-color: var(--color-primary);
}
thead th { position: relative; }

/* ── Table toolbar v2: flex wrap for filter controls ── */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.table-toolbar button, .table-toolbar select {
  flex-shrink: 0;
}

/* ── Compact table columns ── */
table th, table td {
  white-space: nowrap;
}
/* Time columns: tight */
table th:has(+ th), table td {
  padding-left: 8px;
  padding-right: 8px;
}
/* Specific compact cols via data attribute on table */
table[data-sortable] th,
table[data-sortable] td {
  padding: 7px 8px;
}
/* Let text columns breathe but time/code columns stay tight */
table[data-sortable] td:empty { width: 0; }

/* ── Tabs ── */
.tabs { display:flex; gap:4px; border-bottom:0.5px solid var(--color-border); padding-bottom:0; margin-bottom:20px; }
.tab-item {
  padding:8px 16px; font-size:13px; font-weight:500; color:var(--color-text-muted);
  border:none; background:none; cursor:pointer; font-family:inherit;
  border-bottom:2px solid transparent; margin-bottom:-1px;
  text-decoration:none; display:inline-block; border-radius:var(--radius) var(--radius) 0 0;
  transition:color .1s;
}
.tab-item:hover { color:var(--color-text); background:var(--color-bg); }
.tab-item.active { color:var(--color-primary); border-bottom-color:var(--color-primary); }

/* ── Standalone input/select (outside .field wrapper) ── */
.form-control {
  width: 100%;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  background: var(--color-surface);
  border: 0.5px solid var(--color-border-md);
  border-radius: var(--radius);
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--color-primary); }

/* ── Allow column dropdown to overflow table-card ── */
.table-card { overflow: visible; }
.table-card > div[style*="overflow-x"] { overflow-x: auto; }

/* ── Columns dropdown z-index & overflow fix ── */
.table-card { overflow: visible; }
.table-card > div[style*="overflow-x"] { overflow-x: auto; }
.st-cols-drop { z-index: 400 !important; }

/* ── Compact table cells ── */
table th, table td {
  padding: 6px 8px;
}
table[data-sortable] th,
table[data-sortable] td {
  padding: 6px 8px;
}
/* Constrain wide text columns */
table td { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table td.nowrap, table th { white-space: nowrap; }
