/* Goodify SOP System – Dark Minimal UI */

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

:root {
  --bg:       #0f0f13;
  --surface:  #1a1a24;
  --surface2: #23232f;
  --border:   #2e2e3e;
  --accent:   #7c6ff7;
  --accent2:  #a78bfa;
  --text:     #e2e2f0;
  --muted:    #8888a8;
  --ok:       #22c55e;
  --err:      #ef4444;
  --warn:     #f0a500;
  --radius:   8px;
  --sidebar-w: 220px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent2);
}
.logo-icon { font-size: 1.4rem; }

.nav-links {
  list-style: none;
  padding: .75rem 0;
  flex: 1;
}
.nav-links li a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 1.1rem;
  color: var(--muted);
  text-decoration: none;
  border-radius: var(--radius);
  margin: 2px .5rem;
  transition: background .15s, color .15s;
  font-size: .93rem;
}
.nav-links li a:hover,
.nav-links li a.active {
  background: var(--surface2);
  color: var(--text);
}
.nav-links li a.active { color: var(--accent2); font-weight: 600; }
.nav-icon { font-size: 1.1rem; }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.btn-logout {
  display: block;
  text-align: center;
  padding: .5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-decoration: none;
  font-size: .85rem;
  transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: var(--err); color: var(--err); }

/* ── Main layout ── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  padding: 1rem 1.75rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.content {
  padding: 1.75rem;
  flex: 1;
}

/* ── Alerts ── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}
.alert-ok  { background: #14532d44; border: 1px solid var(--ok);  color: #86efac; }
.alert-err { background: #7f1d1d44; border: 1px solid var(--err); color: #fca5a5; }

/* ── Cards / Dashboard ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
}
.stat-card .stat-num {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent2);
}
.stat-card .stat-label {
  font-size: .82rem;
  color: var(--muted);
  margin-top: .2rem;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: .9rem;
}
thead tr { background: var(--surface2); }
th, td {
  padding: .65rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .88rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-success { background: #166534; color: #bbf7d0; }
.btn-danger  { background: #7f1d1d; color: #fca5a5; border: 1px solid var(--err); }
.btn-sm      { padding: .3rem .7rem; font-size: .8rem; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent2); opacity: 1; }

/* ── Forms ── */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 800px;
}
.form-row { margin-bottom: 1rem; }
.form-row label {
  display: block;
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: .35rem;
  font-weight: 500;
}
.form-row input[type=text],
.form-row input[type=file],
.form-row select,
.form-row textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .55rem .8rem;
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.form-row textarea { resize: vertical; min-height: 90px; }
.form-row select option { background: var(--surface2); }
.form-hint { font-size: .78rem; color: var(--muted); margin-top: .25rem; }

.form-actions {
  margin-top: 1.25rem;
  display: flex;
  gap: .75rem;
  align-items: center;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  color: #fff;
}

/* ── Section header ── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* ── Code / JSON ── */
pre.json-view {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-size: .82rem;
  overflow-x: auto;
  color: #a5f3fc;
  white-space: pre;
}

/* ── SOP View ── */
.sop-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}
.sop-section h3 {
  font-size: .85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .6rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .4rem;
}
.sop-section p { font-size: .93rem; white-space: pre-wrap; }

.sop-images {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  margin-top: .5rem;
}
.sop-images img {
  max-height: 140px;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: cover;
  cursor: pointer;
  transition: transform .15s;
}
.sop-images img:hover { transform: scale(1.04); }

/* ── Login page ── */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card h2 { margin-bottom: .25rem; font-size: 1.3rem; }
.login-card p { color: var(--muted); font-size: .88rem; margin-bottom: 1.5rem; }
.login-card input[type=password] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .7rem 1rem;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: .3em;
  margin-bottom: 1rem;
}
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-err { color: var(--err); font-size: .85rem; margin-bottom: .75rem; }

/* ── Responsive ── */
@media (max-width: 700px) {
  .sidebar { display: none; }
  .main-wrap { margin-left: 0; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}
