/*
 * AssetID – application styles
 */

:root {
  --primary: #1a56a4;
  --primary-dark: #143d7a;
  --border: #dee2e6;
  --text: #212529;
  --text-muted: #6c757d;
  --danger: #dc3545;
  --light: #f8f9fa;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #f0f2f5;
  line-height: 1.5;
}

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

/* ── Navbar ── */
.navbar {
  background: var(--primary);
  color: white;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 54px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
  gap: 1rem;
}
.navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
  white-space: nowrap;
  margin-right: 1rem;
}
.navbar-brand:hover { text-decoration: none; }
.navbar-nav {
  display: flex;
  list-style: none;
  gap: 0.1rem;
  flex: 1;
  flex-wrap: wrap;
}
.navbar-nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: 4px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.navbar-nav a:hover { background: rgba(255,255,255,0.15); color: white; text-decoration: none; }
.navbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: rgba(255,255,255,0.85);
  font-size: 0.82rem;
  white-space: nowrap;
}
.navbar-user form { margin: 0; }
.navbar-user button {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: white;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
}
.navbar-user button:hover { background: rgba(255,255,255,0.25); }

/* ── Container ── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Flash ── */
.flash {
  padding: 0.7rem 1rem;
  border-radius: 4px;
  margin-bottom: 1.25rem;
  font-size: 0.875rem;
}
.flash ul { margin: 0.35rem 0 0 1.25rem; }
.flash-notice { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-alert  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ── Card ── */
.card {
  background: white;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  margin-bottom: 1.5rem;
}
.card-header {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
.page-title { font-size: 1.4rem; font-weight: 700; color: #1a1a2e; }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: var(--light);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}
td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.actions { display: flex; gap: 0.4rem; align-items: center; }

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 0.42rem 0.9rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  line-height: 1.5;
  transition: all 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: white; color: #495057; border-color: var(--border); }
.btn-secondary:hover { background: var(--light); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #c82333; }
.btn-sm { padding: 0.22rem 0.55rem; font-size: 0.78rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
label { display: block; font-weight: 500; margin-bottom: 0.3rem; font-size: 0.875rem; }
input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.875rem;
  background: white;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,164,0.1);
}
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: auto; margin-right: 0.4rem; }
.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }
.field_with_errors input,
.field_with_errors select,
.field_with_errors textarea { border-color: var(--danger); }
.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-active           { background: #d4edda; color: #155724; }
.badge-inactive         { background: #e2e3e5; color: #383d41; }
.badge-planned          { background: #cce5ff; color: #004085; }
.badge-under_maintenance { background: #fff3cd; color: #856404; }
.badge-decommissioned   { background: #f8d7da; color: #721c24; }
.role-admin { background: #e8d5f5; color: #5a1a8a; }
.role-staff { background: #d4edda; color: #155724; }
.badge-dtype { background: #e2e3e5; color: #383d41; }

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.3rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb-sep { color: #ced4da; }

/* ── Detail grid ── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem 1.5rem;
}
.detail-item { margin-bottom: 0.5rem; }
.detail-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.15rem;
}
.detail-value { font-size: 0.9rem; }

/* ── Asset hierarchy tree ── */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { padding-left: 1.25rem; margin-left: 0.6rem; border-left: 1px solid #dee2e6; }
.tree li { padding: 0.15rem 0; }
.tree-node {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  margin-left: 0.4rem;
  line-height: 1.35;
}
.tree-node.current-asset {
  background: #e8f0fb;
  border: 1px solid #adc6f0;
}
.tree-cls {
  font-size: 0.7rem;
  background: #f0f0f0;
  color: #666;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  white-space: nowrap;
}
.tree-tag { font-weight: 600; font-size: 0.875rem; }
.tree-name { color: var(--text-muted); font-size: 0.82rem; }

/* ── Section title ── */
.section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── Search form ── */
.search-form {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
  padding: 1rem 1.25rem;
  background: var(--light);
  border-bottom: 1px solid var(--border);
}
.search-form .form-group { margin-bottom: 0; }
.search-form label { font-size: 0.75rem; }
.search-form input,
.search-form select { width: auto; min-width: 130px; }

/* ── Login page ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0f2f5;
}
.login-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  padding: 2rem;
  width: 360px;
}
.login-card h1 { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.25rem; }
.login-card .subtitle { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 1.5rem; }
.login-card .form-actions { border: none; padding: 0; margin-top: 1rem; }

/* ── Inline add form ── */
.inline-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
}
.inline-form .form-group { margin-bottom: 0; }
.inline-form input, .inline-form select { width: auto; min-width: 160px; }
