/* frontend/css/styles.css */

/* ── Google Fonts ──────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface2:     #21262d;
  --border:       #30363d;
  --accent:       #f0a500;
  --accent-hover: #e36b00;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --danger:       #f85149;
  --success:      #3fb950;
  --info:         #58a6ff;

  --badge-siemens-plc-bg:  rgba(0,112,192,.22);
  --badge-siemens-plc-fg:  #58a6ff;
  --badge-drive-bg:        rgba(0,176,240,.15);
  --badge-drive-fg:        #79c0ff;
  --badge-sw-bg:           rgba(112,48,160,.22);
  --badge-sw-fg:           #d2a8ff;
  --badge-other-bg:        rgba(192,0,0,.22);
  --badge-other-fg:        #ff7b72;
  --badge-cables-bg:       rgba(83,129,53,.22);
  --badge-cables-fg:       #7ee787;
  --badge-panels-bg:       rgba(191,143,0,.22);
  --badge-panels-fg:       #e3b341;
  --badge-foc-bg:          rgba(100,100,100,.22);
  --badge-foc-fg:          #8b949e;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Navbar override ────────────────────────────────────────── */
.navbar {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.navbar-brand {
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  font-size: 18px;
  color: var(--accent) !important;
  letter-spacing: -0.5px;
}
.navbar-brand span { color: var(--text-muted); font-weight: 400; }

.nav-link {
  color: var(--text-muted) !important;
  font-weight: 500;
  font-size: 14px;
  padding: 8px 16px !important;
  border-radius: 6px;
  transition: all .2s;
}
.nav-link:hover, .nav-link.active {
  color: var(--accent) !important;
  background: rgba(240,165,0,.1) !important;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: 14px 20px !important;
}

/* ── Form controls ──────────────────────────────────────────── */
.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 5px;
}
.form-control, .form-select {
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 6px !important;
  font-size: 14px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(240,165,0,.15) !important;
}
.form-control::placeholder { color: var(--text-muted) !important; }
.form-select option { background: var(--surface2); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn { font-family: 'DM Sans', sans-serif; font-weight: 600; font-size: 13px; border-radius: 6px; }
.btn-accent {
  background: var(--accent); color: #000;
  border: 1px solid var(--accent);
}
.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #000; }

/* ── Table ──────────────────────────────────────────────────── */
.table-dark-custom { border-collapse: collapse; width: 100%; font-size: 13px; }
.table-dark-custom thead th {
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-dark-custom tbody td {
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-bottom: 1px solid rgba(48,54,61,.6);
  vertical-align: middle;
}
.table-dark-custom tbody tr:hover td { background: rgba(240,165,0,.04); }
.table-dark-custom tbody tr:last-child td { border-bottom: none; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }

/* ── Badges ─────────────────────────────────────────────────── */
.grp-badge {
  display: inline-block; padding: 3px 9px;
  border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.grp-badge.siemens-plc      { background: var(--badge-siemens-plc-bg); color: var(--badge-siemens-plc-fg); }
.grp-badge.siemens-drive     { background: var(--badge-drive-bg);  color: var(--badge-drive-fg); }
.grp-badge.siemens-sw        { background: var(--badge-sw-bg);     color: var(--badge-sw-fg); }
.grp-badge.other-sw          { background: var(--badge-other-bg);  color: var(--badge-other-fg); }
.grp-badge.cables            { background: var(--badge-cables-bg); color: var(--badge-cables-fg); }
.grp-badge.panels            { background: var(--badge-panels-bg); color: var(--badge-panels-fg); }
.grp-badge.foc               { background: var(--badge-foc-bg);   color: var(--badge-foc-fg); }

/* ── Stat cards ─────────────────────────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
}
.stat-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .7px; }
.stat-value { font-size: 26px; font-weight: 700; font-family: 'Space Mono', monospace; margin-top: 4px; }

/* ── Toast ──────────────────────────────────────────────────── */
.toast-custom {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 8px !important;
  font-size: 13px;
  font-weight: 500;
}
.toast-success { border-color: rgba(63,185,80,.4) !important; }
.toast-error   { border-color: rgba(248,81,73,.4) !important; }
.toast-info    { border-color: rgba(88,166,255,.4) !important; }
#toastPlacement { position: fixed; bottom: 24px; right: 24px; z-index: 9999; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }

/* ── Select2 dark theme ─────────────────────────────────────── */
.select2-container--default .select2-selection--single {
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  height: 38px !important;
  display: flex; align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--text) !important;
  line-height: 38px !important;
  padding-left: 12px;
  font-size: 14px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 38px !important;
}
.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(240,165,0,.15) !important;
}
.select2-dropdown {
  background: var(--surface) !important;
  border: 1px solid var(--accent) !important;
  border-radius: 8px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.5) !important;
}
.select2-search--dropdown .select2-search__field {
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 6px !important;
  padding: 6px 10px;
}
.select2-results__option {
  color: var(--text) !important;
  font-size: 13px;
  padding: 9px 12px !important;
}
.select2-results__option--highlighted {
  background: var(--surface2) !important;
  color: var(--text) !important;
}
.select2-results__option[aria-selected="true"] {
  background: rgba(240,165,0,.15) !important;
  color: var(--accent) !important;
}
.select2-search--dropdown { padding: 8px !important; }

/* ── Monospace fields ───────────────────────────────────────── */
.mono { font-family: 'Space Mono', monospace; font-size: 12px; }

/* ── Autofill animation ─────────────────────────────────────── */
@keyframes autofillPulse {
  0%   { border-color: var(--border); }
  40%  { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,165,0,.2); }
  100% { border-color: var(--border); }
}
.autofilled { animation: autofillPulse .6s ease; }

/* ── Modal override ─────────────────────────────────────────── */
.modal-content {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  color: var(--text);
}
.modal-header {
  border-bottom: 1px solid var(--border) !important;
}
.modal-footer {
  border-top: 1px solid var(--border) !important;
}
.btn-close { filter: invert(1); }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
