/*
 * SterilTrack Control Plane — operatör paneli stilleri (Vue 3 SPA).
 * Harici bağımlılık yoktur; sade, hızlı ve klavye dostu bir arayüz hedefler.
 * Motion: yalnız adı geçen özellikler geçiş yapar; reduced-motion saygı görür.
 */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #d8dee7;
  --border-strong: #c3ccd8;
  --text: #17202e;
  --muted: #5c6878;
  --primary: #1f5fd0;
  --primary-hover: #1a4fae;
  --primary-soft: #e8f0fd;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #0a6b46;
  --ok-soft: #e7f5ee;
  --warn: #8a5300;
  --warn-soft: #fdf1dd;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 2px 4px rgba(15, 23, 42, 0.06), 0 6px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12), 0 24px 64px rgba(15, 23, 42, 0.16);
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

/*
 * hidden özniteliği her zaman kazanır: display kuralı olan bileşenlerde
 * aksi halde gizlenmez.
 */
[hidden] {
  display: none !important;
}

/* Vue derlemesi tamamlanana kadar iskelet görünmesin. */
[v-cloak] {
  display: none !important;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1 { font-size: 19px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 15px; margin: 18px 0 8px; }
h4 { font-size: 14px; margin: 14px 0 6px; }
p { margin: 6px 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.num { font-variant-numeric: tabular-nums; }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; }
.warning { color: var(--warn); background: var(--warn-soft); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; }
.ok-text { color: var(--ok); font-size: 13px; }

/* --- Giriş --- */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1000px 500px at 50% -10%, rgba(31, 95, 208, 0.10), transparent 60%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-md);
}

/* --- Genel yerleşim --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: var(--shadow-sm);
}

.card > h3:first-child { margin-top: 0; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.app-title { display: flex; flex-direction: column; gap: 2px; }
.app-title .muted { font-size: 12px; }
.app-header-actions { display: flex; align-items: center; gap: 10px; }

.tabs {
  position: sticky;
  top: 57px;
  z-index: 19;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 16px 0;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: var(--radius) var(--radius) 0 0;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: color 150ms var(--ease), background-color 150ms var(--ease);
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--text);
  font-weight: 600;
  background: var(--bg);
  border-color: var(--border);
  border-bottom-color: var(--bg);
}

.tab .tab-count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid #eed3a5;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.panels { padding: 0 16px 40px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 4px;
}

.panel-head .row-actions { align-items: center; }

/* --- Bildirim (toast) --- */
.notice {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  max-width: min(460px, calc(100vw - 32px));
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  animation: toast-in 180ms var(--ease) both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.notice.ok { border-left: 4px solid var(--ok); }
.notice.error { border-left: 4px solid var(--danger); }

.notice button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

/* --- Formlar --- */
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

label small { font-size: 12px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.grid .wide { grid-column: 1 / -1; }

label.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  align-self: end;
  color: var(--text);
  font-size: 14px;
}

label.checkbox input { width: auto; min-height: 0; }

input,
select,
textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 38px;
  width: 100%;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}

input:hover:not(:disabled),
select:hover:not(:disabled) { border-color: var(--border-strong); }

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
.tab:focus-visible,
a.btn:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

input[type="file"] { padding: 6px 8px; }

.actions,
.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-top: 12px;
}

.field-row label { flex: 1 1 260px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin: 12px 0;
}

.filters label { min-width: 160px; }

/* --- Butonlar --- */
.btn {
  font: inherit;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease),
    color 150ms var(--ease), scale 150ms var(--ease), opacity 150ms var(--ease);
}

.btn:hover:not(:disabled) { background: #eef1f5; border-color: var(--border-strong); }
.btn:active:not(:disabled) { scale: 0.96; }

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

.btn.primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn.danger { color: var(--danger); border-color: #e7b4ae; }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); }

.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover:not(:disabled) { background: #eef1f5; border-color: transparent; }

.btn.small { min-height: 32px; padding: 4px 9px; font-size: 13px; }
.btn.block { width: 100%; }
.btn.icon { min-height: 32px; padding: 2px 10px; }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* --- Açılır aksiyon menüsü --- */
.menu { position: relative; display: inline-block; }

.menu .chev {
  display: inline-block;
  font-size: 10px;
  transition: rotate 150ms var(--ease);
}

.menu .chev.open { rotate: 180deg; }

.menu-panel {
  position: fixed;
  z-index: 80;
  min-width: 220px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: menu-in 140ms var(--ease) both;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: background-color 120ms var(--ease), color 120ms var(--ease);
}

.menu-item:hover { background: var(--primary-soft); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }

.menu-sep {
  height: 1px;
  margin: 6px 4px;
  background: var(--border);
}

/* --- Tablolar --- */
.table-wrap {
  overflow: auto;
  max-height: min(70vh, 900px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin: 12px 0;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  background: #f8fafc;
}

tbody tr { transition: background-color 120ms var(--ease); }
tbody tr:hover { background: #f7f9fc; }
tbody tr:last-child td { border-bottom: 0; }

td .stack { display: flex; flex-direction: column; gap: 3px; }

.empty,
.loading {
  padding: 18px 14px;
  color: var(--muted);
  font-size: 14px;
  margin: 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
}

.empty-state .empty-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 18px;
}

/* --- Durum rozetleri (metin + renk + nokta) --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  background: #eef1f5;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.75;
}

.badge.plain::before { display: none; }

.badge.active { background: var(--ok-soft); color: var(--ok); border-color: #b7e0cc; }
.badge.pending { background: var(--warn-soft); color: var(--warn); border-color: #eed3a5; }
.badge.revoked { background: var(--danger-soft); color: var(--danger); border-color: #f3c2bc; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #eed3a5; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: #f3c2bc; }

/* --- Çevrimiçi/çevrimdışı (son görülme) --- */
.presence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.presence::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--border-strong);
}

.presence.online {
  color: var(--ok);
  font-weight: 600;
}

.presence.online::before {
  background: var(--ok);
  animation: presence-pulse 2.4s var(--ease) infinite;
}

@keyframes presence-pulse {
  0% { box-shadow: 0 0 0 0 rgba(10, 107, 70, 0.35); }
  70% { box-shadow: 0 0 0 6px rgba(10, 107, 70, 0); }
  100% { box-shadow: 0 0 0 0 rgba(10, 107, 70, 0); }
}

.machine-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

/* --- Diyaloglar --- */
dialog {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  width: min(920px, 94vw);
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: dialog-in 180ms var(--ease) both;
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  animation: backdrop-in 180ms var(--ease) both;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dialog-body { padding: 18px; }

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.meta-line { word-break: break-word; }

.code-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.code-row code {
  flex: 1 1 260px;
  background: #f4f6f8;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  word-break: break-all;
}

.code-block,
.notes {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  line-height: 1.55;
  overflow: auto;
  max-height: 55vh;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

/* --- Toplu sürüm yükleme --- */
.bulk-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bulk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  font-size: 13px;
}

.bulk-row .file-name { font-weight: 600; word-break: break-all; }
.bulk-row .detected { color: var(--muted); }
.bulk-row .result-ok { color: var(--ok); font-weight: 600; }
.bulk-row .result-dup { color: var(--warn); font-weight: 600; }
.bulk-row .result-err { color: var(--danger); font-weight: 600; }

.progress {
  height: 6px;
  border-radius: 999px;
  background: #e6ebf2;
  overflow: hidden;
  margin-top: 10px;
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 200ms var(--ease);
}

.hint { font-size: 12px; color: var(--muted); }

/* Panel içeriği girişte yumuşak yükselir (yalnız oturum açılışında; tek seferlik). */
.app-enter > * { animation: rise 220ms var(--ease) both; }
.app-enter > *:nth-child(2) { animation-delay: 60ms; }
.app-enter > *:nth-child(3) { animation-delay: 110ms; }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 720px) {
  .panels { padding: 0 10px 32px; }
  .panel-head { margin-top: 14px; }
  .app-header { align-items: flex-start; }
  .tabs { top: 0; }
  dialog { width: 96vw; }
  .dialog-body { padding: 14px; }
  .menu-panel { right: auto; left: 0; }
}
