/* ============================================================
   Cre8Trends CRM — stylesheet
   Palette: black + vivid orange (cre8trends brand), functional
   status colors for pipeline/outcome coding.
   ============================================================ */

:root {
  --black: #000000;
  --panel-black: #121212;
  --bg: #F7F6F3;
  --panel: #FFFFFF;
  --border: #E6E3DD;
  --text: #1A1A1A;
  --text-muted: #6B6B6B;

  --orange: #FF6B1A;
  --orange-dark: #E0550A;
  --blue: #0E6BA8;
  --green: #1E8E5A;
  --amber: #D89614;
  --red: #C0392B;

  --font-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2 { font-family: var(--font-display); margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.9rem; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--black);
  color: #EDEDED;
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.4rem 0.3rem 1.6rem;
  margin-bottom: 0.6rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-glow {
  position: absolute;
  top: -30px;
  left: -10px;
  width: 130px;
  height: 130px;
  background: radial-gradient(circle, rgba(255,107,26,0.35) 0%, rgba(255,107,26,0) 70%);
  pointer-events: none;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--orange);
  position: relative;
}

.brand-word {
  font-size: 0.95rem;
  font-weight: 500;
  color: #C9C9C9;
  position: relative;
}

.nav { display: flex; flex-direction: column; gap: 0.15rem; margin-top: 1rem; flex: 1; }

.nav-link {
  color: #C9C9C9;
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 500;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,0.06); text-decoration: none; color: #fff; }
.nav-link.active {
  background: rgba(255,107,26,0.12);
  color: #fff;
  border-left-color: var(--orange);
}

.sidebar-footer { border-top: 1px solid rgba(255,255,255,0.08); padding-top: 1rem; }

.user-chip { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--orange); color: #111;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-family: var(--font-display); flex-shrink: 0;
}
.user-name { font-size: 0.88rem; font-weight: 600; color: #fff; }
.user-role { font-size: 0.76rem; color: #9A9A9A; }
.logout-link { font-size: 0.82rem; color: #9A9A9A; }
.logout-link:hover { color: #fff; }

.main { flex: 1; padding: 2.1rem 2.4rem 3rem; min-width: 0; }

/* ---------- Page head ---------- */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-head-actions { display: flex; align-items: center; gap: 0.8rem; }
.subtle { color: var(--text-muted); font-size: 0.9rem; margin: 0.25rem 0 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: var(--font-body);
}
.btn-primary { background: var(--orange); color: #16110D; }
.btn-primary:hover { background: var(--orange-dark); text-decoration: none; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #EFEDE8; text-decoration: none; }
.btn-block { width: 100%; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

/* ---------- Stat tiles ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.8rem;
}
.stat-tile {
  background: var(--panel);
  border-left: 4px solid var(--tile-color, var(--orange));
  border-radius: 6px;
  padding: 1rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.stat-value { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.82rem; }

/* ---------- Panels ---------- */
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.3rem; }
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.3rem 1.4rem;
  margin-bottom: 1.3rem;
}

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.76rem;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.table td { padding: 0.6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #FBFAF8; }
.row-overdue { background: #FDF3F1; }
.row-actions { display: flex; gap: 0.7rem; align-items: center; white-space: nowrap; }
.empty-note { color: var(--text-muted); padding: 1.3rem 0.6rem; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 600; color: var(--badge-color);
  padding: 0.15rem 0;
}
.badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: var(--badge-color); display: inline-block;
}

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
input, select, textarea {
  font-family: var(--font-body);
  font-size: 0.92rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--orange); outline-offset: 1px; border-color: var(--orange); }
textarea { resize: vertical; font-family: var(--font-body); }

.form-card { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 1.6rem; max-width: 780px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.4rem; margin-bottom: 1rem; }
.form-inline-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem 1.2rem; align-items: end; }
.form-inline-grid .span-2 { grid-column: span 3; }
.form-actions { display: flex; gap: 0.8rem; margin-top: 0.4rem; }
.checkbox-row { flex-direction: row; align-items: center; gap: 0.5rem; font-size: 0.88rem; color: var(--text); }
.checkbox-row input { width: auto; }
.fu-fields { display: grid; grid-template-columns: 1fr 1fr 2fr; gap: 1rem; background: #FBFAF8; border: 1px dashed var(--border); border-radius: 6px; padding: 0.9rem; }
.fu-fields.hidden { display: none; }

.filter-bar { display: flex; gap: 0.7rem; margin-bottom: 1.3rem; flex-wrap: wrap; }
.filter-bar input[type="text"] { min-width: 240px; }

.inline-form { display: inline-flex; gap: 0.6rem; align-items: center; margin: 0; }
.link-action { background: none; border: none; padding: 0; color: var(--orange-dark); font-size: 0.85rem; font-weight: 600; cursor: pointer; font-family: var(--font-body); }
.link-action:hover { text-decoration: underline; }
.link-danger { color: var(--red); }

.reset-pw { position: relative; }
.reset-pw summary { list-style: none; }
.reset-pw summary::-webkit-details-marker { display: none; }
.reset-pw-form { position: absolute; z-index: 5; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem; margin-top: 0.4rem; box-shadow: 0 4px 14px rgba(0,0,0,0.08); }

/* ---------- Detail page ---------- */
.detail-grid { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; align-items: start; }
.detail-meta dl { display: grid; grid-template-columns: auto 1fr; gap: 0.4rem 0.8rem; font-size: 0.85rem; margin: 0 0 1rem; }
.detail-meta dt { color: var(--text-muted); }
.detail-meta dd { margin: 0; }
.notes-box { background: #FBFAF8; border: 1px solid var(--border); border-radius: 6px; padding: 0.8rem; font-size: 0.85rem; white-space: pre-wrap; }

/* ---------- Tabs & pagination ---------- */
.tab-bar { display: flex; gap: 1.4rem; border-bottom: 1px solid var(--border); margin-bottom: 1.3rem; }
.tab-bar a { padding-bottom: 0.7rem; color: var(--text-muted); font-weight: 600; font-size: 0.88rem; border-bottom: 2px solid transparent; }
.tab-bar a:hover { text-decoration: none; color: var(--text); }
.tab-bar a.active { color: var(--orange-dark); border-bottom-color: var(--orange); }

.pagination { display: flex; gap: 0.4rem; margin-top: 1.2rem; }
.pagination a { padding: 0.35rem 0.7rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; color: var(--text); }
.pagination a:hover { text-decoration: none; background: #EFEDE8; }
.pagination a.active { background: var(--orange); color: #16110D; border-color: var(--orange); }

/* ---------- Alerts ---------- */
.alert { padding: 0.7rem 1rem; border-radius: 6px; font-size: 0.88rem; margin-bottom: 1.1rem; }
.alert-success { background: #EAF7EF; color: #14663F; border: 1px solid #C6E9D3; }
.alert-error { background: #FCEBEA; color: #8F291D; border: 1px solid #F3C7C2; }

/* ---------- Auth pages ---------- */
.auth-page {
  background: var(--black);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-image: radial-gradient(circle at 50% 0%, rgba(255,107,26,0.18) 0%, rgba(0,0,0,0) 55%);
}
.auth-card {
  background: var(--panel);
  border-radius: 10px;
  padding: 2.4rem 2.2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.auth-brand { position: relative; display: inline-block; margin-bottom: 1rem; }
.auth-brand .brand-glow { top: -40px; left: -35px; width: 110px; height: 110px; }
.auth-brand .brand-mark { font-size: 1.6rem; }
.auth-card h1 { font-size: 1.3rem; margin-bottom: 0.2rem; }
.auth-sub { color: var(--text-muted); font-size: 0.86rem; margin: 0 0 1.3rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.9rem; text-align: left; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 1rem; }
  .brand { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; margin-top: 0; }
  .sidebar-footer { border-top: none; margin-left: auto; padding-top: 0; }
  .main { padding: 1.4rem; }
  .panel-grid, .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .form-inline-grid { grid-template-columns: 1fr 1fr; }
  .form-inline-grid .span-2 { grid-column: span 2; }
}
