/* ------------------------------------------------------------------
   Şantiye ERP — arayüz stilleri

   Tasarım kararları:
   - Harici font/CDN kullanılmaz. Şantiye bilgisayarları ve zayıf internet
     bağlantısı düşünülerek her şey yerel ve sistem fontlarıyla çalışır.
   - Yoğun veri tabloları esas alınmıştır: satır yüksekliği düşük,
     sayılar tablo rakamlarıyla (tabular-nums) hizalı.
   - Palet şantiye ekipmanından alınmıştır: koyu mürekkep, beton grisi,
     makine sarısı. Renk yalnızca durum bildirir, süs değildir.
------------------------------------------------------------------- */

:root {
  --ink:        #16202c;
  --ink-soft:   #2b3949;
  --concrete:   #eef1f4;
  --surface:    #ffffff;
  --line:       #d5dbe2;
  --line-soft:  #e6eaef;
  --text:       #1d2733;
  --text-muted: #61707f;

  --signal:     #e0a21a;   /* makine sarısı — birincil eylem ve vurgu */
  --signal-dim: #fdf4de;
  --danger:     #b3261e;
  --danger-dim: #fbeceb;
  --success:    #1e7a4b;
  --success-dim:#e8f5ee;
  --info:       #1f5f9e;
  --info-dim:   #e9f1f9;

  --radius:     3px;
  --rail-width: 232px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--concrete);
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: 1px;
}

/* --------------------------- Yerleşim --------------------------- */

.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail-width);
  flex: 0 0 var(--rail-width);
  background: var(--ink);
  color: #c8d2dd;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.rail-brand {
  padding: 16px 18px 14px;
  border-bottom: 1px solid #24313f;
}
.rail-brand strong { color: #fff; font-size: 15px; display: block; letter-spacing: .01em; }
.rail-brand span { color: #7d8b9a; font-size: 11px; }

.rail-nav { padding: 8px 0 20px; flex: 1; }
.rail-group { padding: 14px 18px 4px; color: #6b7a89; font-size: 11px; letter-spacing: .04em; }
.rail-nav a {
  display: block;
  padding: 7px 18px;
  color: #c8d2dd;
  border-left: 3px solid transparent;
}
.rail-nav a:hover { background: #1d2937; color: #fff; text-decoration: none; }
.rail-nav a.active {
  background: #1d2937;
  color: #fff;
  border-left-color: var(--signal);
  font-weight: 600;
}

.rail-user {
  padding: 12px 18px;
  border-top: 1px solid #24313f;
  font-size: 12px;
}
.rail-user .name { color: #fff; font-weight: 600; }
.rail-user .role { color: #7d8b9a; }
.rail-user form { margin-top: 8px; }
.rail-user button {
  background: none; border: 1px solid #3a4959; color: #c8d2dd;
  padding: 4px 10px; border-radius: var(--radius); cursor: pointer; font-size: 12px;
}
.rail-user button:hover { background: #24313f; color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar .title { flex: 1; min-width: 200px; }
.topbar .subtitle { color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.content { padding: 20px 24px 48px; flex: 1; }

/* --------------------------- Panolar --------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.panel-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}
.panel-head h2 { flex: 1; }
.panel-body { padding: 16px; }
.panel-body.tight { padding: 0; }

/* --------------------------- Tablolar --------------------------- */

.table-wrap { overflow-x: auto; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  text-align: left;
  padding: 9px 12px;
  background: #f4f6f8;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}
table.data tbody tr:hover { background: #f8fafb; }
table.data tr.inactive td { color: var(--text-muted); }
table.data td.num, table.data th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.data td.code {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink-soft);
}
table.data td.actions { text-align: right; white-space: nowrap; }

.empty {
  padding: 40px 16px;
  text-align: center;
  color: var(--text-muted);
}
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* --------------------------- Formlar --------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px 18px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field.span-2 { grid-column: span 2; }
.field.span-full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field .hint { font-size: 12px; color: var(--text-muted); }
.field .err { font-size: 12px; color: var(--danger); }

input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="email"], input[type="search"], select, textarea {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:disabled, select:disabled, input[readonly] {
  background: #f4f6f8;
  color: var(--text-muted);
}
input.has-error, select.has-error { border-color: var(--danger); }
textarea { resize: vertical; min-height: 72px; }
input[type="number"] { font-variant-numeric: tabular-nums; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: auto; }

.form-actions {
  display: flex;
  gap: 8px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--line-soft);
}

/* --------------------------- Düğmeler --------------------------- */

.btn {
  display: inline-block;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f4f6f8; text-decoration: none; }
.btn-primary {
  background: var(--signal);
  border-color: #c98f14;
  color: #1a1204;
}
.btn-primary:hover { background: #cf9517; }
.btn-danger { background: #fff; border-color: #e2b6b3; color: var(--danger); }
.btn-danger:hover { background: var(--danger-dim); }
.btn-sm { padding: 4px 9px; font-size: 12px; font-weight: 500; }
.btn-link { border: none; background: none; padding: 4px 6px; color: var(--info); }
.btn-link:hover { background: none; text-decoration: underline; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* --------------------------- Rozetler --------------------------- */

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 2px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-ok      { background: var(--success-dim); color: var(--success); border-color: #bfe0cd; }
.badge-warn    { background: var(--signal-dim);  color: #8a6207;       border-color: #f0dca8; }
.badge-danger  { background: var(--danger-dim);  color: var(--danger); border-color: #ecc4c1; }
.badge-info    { background: var(--info-dim);    color: var(--info);   border-color: #c3d8ec; }
.badge-muted   { background: #eef1f4; color: var(--text-muted); border-color: var(--line); }

/* --------------------------- Bildirimler --------------------------- */

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; border: 1px solid; font-size: 13px; }
.flash-success { background: var(--success-dim); border-color: #bfe0cd; color: #145c39; }
.flash-error   { background: var(--danger-dim);  border-color: #ecc4c1; color: #8c1d17; }
.flash-warning { background: var(--signal-dim);  border-color: #f0dca8; color: #7a5606; }
.flash-info    { background: var(--info-dim);    border-color: #c3d8ec; color: #17497a; }

/* --------------------------- Filtre çubuğu --------------------------- */

.filters {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #f8fafb;
  border-bottom: 1px solid var(--line-soft);
}
.filters .field { min-width: 160px; }
.filters .field label { font-size: 11px; }

/* --------------------------- Gösterge kartları --------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .value {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--ink);
}
.stat .label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat.alert { border-left: 3px solid var(--danger); }
.stat.warn  { border-left: 3px solid var(--signal); }

/* --------------------------- Ağaç görünümü --------------------------- */

.tree { font-size: 13px; }
.tree ul { list-style: none; margin: 0; padding-left: 22px; }
.tree > ul { padding-left: 0; }
.tree li { padding: 3px 0; border-left: 1px solid var(--line-soft); padding-left: 12px; margin-left: 4px; }
.tree > ul > li { border-left: none; padding-left: 0; margin-left: 0; }
.tree .node { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: var(--radius); }
.tree .node:hover { background: #f4f6f8; }
.tree .node .path { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 12px; }
.tree .node .count { color: var(--text-muted); font-size: 12px; }
.tree .lvl-1 > .node { font-weight: 600; }

/* --------------------------- Giriş sayfası --------------------------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  border-top: 3px solid var(--signal);
}
.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-card .sub { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; text-align: center; padding: 9px; }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* --------------------------- Sayfalama --------------------------- */

.pager { display: flex; gap: 6px; align-items: center; padding: 12px 16px; font-size: 13px; }
.pager .spacer { flex: 1; color: var(--text-muted); }
.pager a, .pager span {
  padding: 4px 9px; border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--text); background: #fff;
}
.pager .current { background: var(--ink); color: #fff; border-color: var(--ink); }
.pager a:hover { background: #f4f6f8; text-decoration: none; }

/* --------------------------- Yardımcılar --------------------------- */

.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-12 { margin-bottom: 12px; }
.row-split { display: flex; gap: 16px; flex-wrap: wrap; }
.row-split > * { flex: 1; min-width: 280px; }

/* --------------------------- Hata sayfaları --------------------------- */

.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.error-page .box { max-width: 460px; }
.error-page .code {
  font-size: 44px;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.error-page p { color: var(--text-muted); }
.error-trace {
  text-align: left; background: #1d2733; color: #d7e0ea; padding: 14px;
  border-radius: var(--radius); font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; overflow: auto; max-height: 340px; margin-top: 16px;
}

/* --------------------------- Duyarlılık --------------------------- */

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .rail { width: 100%; flex: none; height: auto; position: static; }
  .rail-nav { display: flex; flex-wrap: wrap; padding: 6px; }
  .rail-nav a { border-left: none; border-bottom: 3px solid transparent; padding: 6px 12px; }
  .rail-nav a.active { border-left: none; border-bottom-color: var(--signal); }
  .rail-group { display: none; }
  .content { padding: 16px 12px 40px; }
  .topbar { padding: 12px 14px; }
  .field.span-2 { grid-column: span 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media print {
  .rail, .topbar .actions, .filters, .form-actions { display: none; }
  body { background: #fff; }
  .panel { border: none; }
}
