/* ============================================================
   DeviceDoc – Stylesheet
   Industrial / technical aesthetic, mobile-first
   ============================================================ */

:root {
  --navy:    #1a2744;
  --navy2:   #243058;
  --steel:   #3b5998;  /* accent blue */
  --amber:   #e8a020;  /* highlight / warning */
  --green:   #2e7d52;
  --red:     #b03030;
  --bg:      #f0f2f5;
  --surface: #ffffff;
  --surface2:#f7f8fa;
  --border:  #d8dce5;
  --text:    #1c1e27;
  --text2:   #5a6070;
  --radius:  6px;
  --shadow:  0 1px 4px rgba(0,0,0,.10), 0 4px 16px rgba(0,0,0,.06);
  --font:    'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono:    'Consolas', 'Menlo', monospace;
}

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

html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--text); min-height: 100vh; }

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

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--navy);
  display: flex; align-items: center; flex-wrap: wrap;
  padding: 0 1rem; height: 52px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.topbar-brand {
  display: flex; align-items: center; gap: .5rem;
  color: #fff; font-weight: 700; font-size: 1.05rem;
  letter-spacing: .03em; text-decoration: none;
  flex: 1;
}
.topbar-brand svg { color: var(--amber); }

.nav-toggle {
  display: flex; flex-direction: column; gap: 4px;
  background: none; border: none; cursor: pointer; padding: 6px;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px;
  background: rgba(255,255,255,.8); border-radius: 2px;
  transition: .2s;
}

.nav-menu {
  display: none; flex-direction: column;
  width: 100%; background: var(--navy2);
  border-top: 1px solid rgba(255,255,255,.08);
  padding: .5rem 0;
}
.nav-menu.open { display: flex; }

.nav-link {
  display: flex; align-items: center; gap: .55rem;
  padding: .65rem 1.2rem; color: rgba(255,255,255,.85);
  font-size: .9rem; transition: background .15s;
  text-decoration: none;
}
.nav-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-sep { height: 1px; background: rgba(255,255,255,.1); margin: .4rem 0; }
.nav-user {
  display: flex; align-items: center; gap: .55rem;
  padding: .6rem 1.2rem; color: rgba(255,255,255,.5);
  font-size: .82rem;
}
.nav-logout { color: #e88080; }

@media (min-width: 768px) {
  .nav-toggle { display: none; }
  .nav-menu {
    display: flex !important; flex-direction: row;
    width: auto; background: none; border: none;
    padding: 0; align-items: center;
  }
  .nav-sep { width: 1px; height: 20px; margin: 0 .2rem; }
  .nav-link { padding: .3rem .75rem; font-size: .85rem; border-radius: var(--radius); }
  .nav-user { padding: .3rem .5rem; }
}

/* ── Main content ───────────────────────────────────────── */
.main-content { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem;
  margin-bottom: 1.25rem; padding-bottom: .75rem;
  border-bottom: 2px solid var(--border);
}
.page-header h1 {
  font-size: 1.4rem; font-weight: 700;
  color: var(--navy); letter-spacing: -.01em;
}
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ── Flash messages ─────────────────────────────────────── */
.flash {
  padding: .8rem 1rem; border-radius: var(--radius);
  margin-bottom: 1rem; font-size: .9rem; font-weight: 500;
}
.flash-success { background: #d4edda; color: #1a5c30; border-left: 4px solid var(--green); }
.flash-error   { background: #fde8e8; color: #7a1a1a; border-left: 4px solid var(--red); }
.flash-info    { background: #ddeeff; color: #1a3a6a; border-left: 4px solid var(--steel); }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  margin-bottom: 1rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1.1rem; background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: .95rem; color: var(--navy);
}
.card-body { padding: 1rem 1.1rem; }

/* ── Device grid ────────────────────────────────────────── */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 1rem;
}
.device-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s;
  text-decoration: none; color: inherit;
}
.device-card:hover { transform: translateY(-2px); box-shadow: 0 4px 20px rgba(0,0,0,.13); text-decoration: none; }
.device-card-header {
  background: var(--navy); color: #fff;
  padding: .75rem 1rem;
  display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem;
}
.device-sn {
  font-family: var(--mono); font-size: .95rem; font-weight: 600;
  letter-spacing: .03em;
}
.device-type { font-size: .8rem; color: rgba(255,255,255,.65); margin-top: .2rem; }
.device-card-body { padding: .8rem 1rem; flex: 1; }
.device-meta { font-size: .82rem; color: var(--text2); display: flex; gap: 1rem; flex-wrap: wrap; margin-top: .5rem; }

/* ── Status badges ──────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .55rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap;
}
.badge-production { background: #e8f4fd; color: #1455a0; }
.badge-active      { background: #d4f0e0; color: #1a5c30; }
.badge-maintenance { background: #fff3cd; color: #7a5200; }
.badge-retired     { background: #f0f0f0; color: #666; }

/* ── Log entry types ────────────────────────────────────── */
.entry-type {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .75rem; font-weight: 600;
  padding: .18rem .5rem; border-radius: var(--radius);
  text-transform: uppercase; letter-spacing: .04em;
}
.entry-production { background: #ddeeff; color: #1455a0; }
.entry-repair      { background: #fde8e8; color: #7a1a1a; }
.entry-maintenance { background: #fff3cd; color: #7a5200; }
.entry-note        { background: #f0f0f0; color: #555; }

/* ── Log timeline ───────────────────────────────────────── */
.timeline { position: relative; padding-left: 2.2rem; }
.timeline::before {
  content: ''; position: absolute; left: .7rem; top: 0; bottom: 0;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 1.2rem; }
.timeline-dot {
  position: absolute; left: -1.85rem; top: .25rem;
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--steel);
}
.timeline-dot-production { background: var(--steel); }
.timeline-dot-repair      { background: var(--red); }
.timeline-dot-maintenance { background: var(--amber); }
.timeline-dot-note        { background: #aaa; }
.timeline-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .85rem 1rem;
}
.timeline-title { font-weight: 600; font-size: .95rem; margin-bottom: .25rem; }
.timeline-meta  { font-size: .8rem; color: var(--text2); display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.timeline-desc  { font-size: .88rem; white-space: pre-wrap; }

/* ── Forms ──────────────────────────────────────────────── */
.form-grid { display: grid; gap: .9rem; }
@media (min-width: 600px) {
  .form-grid-2 { grid-template-columns: 1fr 1fr; }
}
.form-group { display: flex; flex-direction: column; gap: .3rem; }
label { font-size: .85rem; font-weight: 600; color: var(--text2); }
input[type=text], input[type=password], input[type=email],
input[type=number], input[type=date], select, textarea {
  padding: .55rem .75rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-family: var(--font); font-size: .9rem;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--steel);
  box-shadow: 0 0 0 3px rgba(59,89,152,.15);
}
textarea { resize: vertical; min-height: 90px; }

/* ── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem; border-radius: var(--radius);
  font-family: var(--font); font-size: .88rem; font-weight: 600;
  cursor: pointer; border: none; transition: .15s; text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn-primary   { background: var(--navy); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-success   { background: var(--green); color: #fff; }
.btn-danger    { background: var(--red); color: #fff; }
.btn-amber     { background: var(--amber); color: #fff; }
.btn-sm        { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg        { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-icon      { padding: .45rem; }

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th { background: var(--surface2); padding: .65rem .9rem; text-align: left; font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text2); border-bottom: 2px solid var(--border); }
td { padding: .65rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface2); }

/* ── Search ─────────────────────────────────────────────── */
.search-bar {
  display: flex; gap: .5rem; margin-bottom: 1.25rem;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .6rem .75rem;
  align-items: center;
}
.search-bar input { border: none; flex: 1; font-size: 1rem; background: none; outline: none; }
.search-bar button { flex-shrink: 0; }

/* ── Properties table ───────────────────────────────────── */
.prop-table { width: 100%; }
.prop-table th:first-child, .prop-table td:first-child { width: 40%; }
.prop-key { font-weight: 600; color: var(--text2); font-size: .83rem; }
.prop-val { font-size: .9rem; }

/* ── Attachments ────────────────────────────────────────── */
.attach-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .75rem;
}
.attach-item {
  border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--surface2);
  display: flex; flex-direction: column; align-items: center;
  font-size: .78rem; text-align: center;
  transition: box-shadow .15s;
}
.attach-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.attach-thumb { width: 100%; height: 90px; object-fit: cover; }
.attach-icon  { width: 100%; height: 90px; display: flex; align-items: center; justify-content: center; background: var(--surface); }
.attach-icon svg { color: var(--text2); }
.attach-name { padding: .4rem .5rem; word-break: break-word; color: var(--text); line-height: 1.3; }
.attach-actions { padding: .3rem; display: flex; gap: .3rem; }

/* ── Upload zone ────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 1.5rem 1rem; text-align: center;
  cursor: pointer; transition: border-color .2s, background .2s;
  font-size: .88rem; color: var(--text2);
}
.upload-zone:hover, .upload-zone.drag { border-color: var(--steel); background: #f0f5ff; }
.upload-zone input { display: none; }

/* ── Login page ─────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--navy);
  padding: 1rem;
}
.login-box {
  background: var(--surface); border-radius: 10px;
  padding: 2rem 2rem 2.5rem; width: 100%; max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,.35);
}
.login-logo {
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  font-size: 1.5rem; font-weight: 800; color: var(--navy);
  margin-bottom: 1.75rem; letter-spacing: -.02em;
}
.login-logo svg { color: var(--amber); }

/* ── Utilities ──────────────────────────────────────────── */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.mt-1 { margin-top: .4rem; }
.mt-2 { margin-top: .75rem; }
.mt-3 { margin-top: 1.25rem; }
.mb-1 { margin-bottom: .4rem; }
.mb-2 { margin-bottom: .75rem; }
.mb-3 { margin-bottom: 1.25rem; }
.text-sm   { font-size: .82rem; }
.text-muted { color: var(--text2); }
.text-mono  { font-family: var(--mono); }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text2);
}
.empty-state svg { margin-bottom: .75rem; opacity: .35; }
.empty-state p { font-size: .95rem; }

/* ── Brand responsive ───────────────────────────────────── */
.brand-short { display: none; }
@media (max-width: 480px) {
  .brand-full  { display: none; }
  .brand-short { display: inline; }
}

/* ── Language switcher ──────────────────────────────────── */
.lang-switch {
  display: flex; align-items: center; gap: .2rem;
  padding: .4rem 1rem;
}
.lang-btn {
  padding: .22rem .55rem; border-radius: 4px;
  font-size: .75rem; font-weight: 700; letter-spacing: .06em;
  color: rgba(255,255,255,.55); text-decoration: none;
  transition: .15s;
}
.lang-btn:hover { color: #fff; text-decoration: none; }
.lang-active { background: rgba(255,255,255,.18); color: #fff !important; }

@media (min-width: 768px) {
  .lang-switch { padding: .2rem .3rem; }
}
