/* =====================================================================
   SoCal Window Pros CRM - Stylesheet
   ===================================================================== */

:root {
  --brand-red: #ED1C24;
  --brand-red-dark: #C8161C;
  --brand-black: #111111;
  --gray-50: #f6f7f9;
  --gray-100: #eef0f3;
  --gray-200: #e2e5ea;
  --gray-300: #cbd0d8;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --green: #0a7a3c;
  --green-bg: #e7f7ee;
  --amber: #92660a;
  --amber-bg: #fdf3d6;
  --blue: #1d4ed8;
  --blue-bg: #e8edfc;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--brand-black);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; }
img { max-width: 100%; }

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

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .logo-link { display: flex; align-items: center; flex-shrink: 0; }
.topbar .logo-link img { height: 42px; }

.main-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.main-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--gray-700); text-decoration: none; font-size: 11px; font-weight: 600;
  padding: 6px 10px; border-radius: 8px; white-space: nowrap;
}
.main-nav a svg { width: 20px; height: 20px; stroke: var(--gray-700); }
.main-nav a:hover { background: var(--gray-100); }
.main-nav a.active { color: var(--brand-red); }
.main-nav a.active svg { stroke: var(--brand-red); }

.topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.topbar-search {
  display: none;
}
@media (min-width: 900px) {
  .topbar-search { display: block; }
  .topbar-search input {
    width: 200px; padding: 8px 12px; border-radius: 20px; border: 1px solid var(--gray-300); font-size: 13px;
  }
}

.btn-add-lead {
  background: #fff; border: 1.5px solid var(--blue); color: var(--blue);
  border-radius: 20px; padding: 7px 14px; font-weight: 700; font-size: 13px; cursor: pointer;
  white-space: nowrap;
}
.btn-add-lead:hover { background: var(--blue-bg); }

.account-menu { position: relative; }
.account-trigger {
  display: flex; align-items: center; gap: 6px; cursor: pointer; background: none; border: none; padding: 4px;
}
.account-trigger img { height: 34px; }
.account-dropdown {
  display: none; position: absolute; right: 0; top: 50px; background: #fff; border-radius: 10px;
  box-shadow: var(--shadow); border: 1px solid var(--gray-200); min-width: 220px; z-index: 200; overflow: hidden;
}
.account-dropdown.open { display: block; }
.account-dropdown .who { padding: 14px 16px; border-bottom: 1px solid var(--gray-200); }
.account-dropdown .who strong { display: block; font-size: 14px; }
.account-dropdown .who span { font-size: 12px; color: var(--gray-500); text-transform: capitalize; }
.account-dropdown a {
  display: block; padding: 11px 16px; color: var(--brand-black); font-size: 14px; font-weight: 500;
}
.account-dropdown a:hover { background: var(--gray-50); text-decoration: none; }

.nav-toggle { display: none; background: none; border: none; cursor: pointer; }
@media (max-width: 880px) {
  .main-nav { display: none; flex-direction: column; position: absolute; top: var(--topbar-h); left: 0; right: 0; background: #fff; border-bottom: 1px solid var(--gray-200); padding: 8px; box-shadow: var(--shadow); }
  .main-nav.open { display: flex; }
  .main-nav a { flex-direction: row; justify-content: flex-start; font-size: 14px; padding: 10px 12px; }
  .nav-toggle { display: block; }
}

.content { padding: 20px; max-width: 1500px; width: 100%; margin: 0 auto; }
.page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.page-header h1 { font-size: 22px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .03em; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cards / widgets ---------- */
.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--gray-200);
  padding: 18px; margin-bottom: 18px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-header h3 { font-size: 16px; margin: 0; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat { text-align: center; }
.stat .label { font-size: 11px; text-transform: uppercase; color: var(--gray-500); font-weight: 700; letter-spacing: .04em; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat .value.green { color: var(--green); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 7px; font-weight: 600; font-size: 13.5px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none; line-height: 1.2;
}
.btn-primary { background: var(--brand-red); color: #fff; }
.btn-primary:hover { background: var(--brand-red-dark); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--gray-300); color: var(--brand-black); }
.btn-secondary:hover { background: var(--gray-100); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #1738a8; color: #fff; }
.btn-danger { background: #fff; border-color: #e9b4b6; color: #9b1c1c; }
.btn-danger:hover { background: #fde8e8; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 1px solid var(--gray-300); background: #fff; }
.btn-icon:hover { background: var(--gray-100); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 12.5px; margin: 0 0 5px; color: var(--gray-700); }
.field { margin-bottom: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], input[type=time], input[type=datetime-local],
select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--gray-300); border-radius: 7px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--brand-black);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-red); outline-offset: -1px; border-color: var(--brand-red); }
.required { color: var(--brand-red); }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 160px; }
.help-text { font-size: 12px; color: var(--gray-500); margin-top: 4px; }
fieldset { border: 1px solid var(--gray-200); border-radius: var(--radius); margin: 0 0 16px; padding: 14px; }
legend { font-weight: 700; padding: 0 6px; color: var(--gray-700); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; background: #fff; }
table.list th, table.list td { padding: 10px 12px; border-bottom: 1px solid var(--gray-200); text-align: left; font-size: 13.5px; }
table.list th { background: var(--gray-50); font-size: 11.5px; text-transform: uppercase; color: var(--gray-500); letter-spacing: .03em; }
table.list tr:hover td { background: var(--gray-50); }
.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--gray-200); }
.table-wrap table.list { box-shadow: none; border: none; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: #fde8e8; color: #9b1c1c; }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: var(--gray-100); color: var(--gray-700); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; background: #d8dce3; border-radius: 8px 8px 0 0; overflow-x: auto; }
.tabs a {
  padding: 11px 16px; font-size: 13.5px; font-weight: 700; color: #fff; background: #8b93a3;
  white-space: nowrap; text-decoration: none;
}
.tabs a:first-child { border-radius: 8px 0 0 0; }
.tabs a.active { background: #4a5568; }
.tab-panel { background: #fff; border: 1px solid var(--gray-200); border-top: none; border-radius: 0 0 var(--radius) var(--radius); padding: 18px; box-shadow: var(--shadow); }

/* ---------- Two column record layout (Contacts etc.) ---------- */
.record-layout { display: flex; gap: 18px; }
.record-sidebar { width: 250px; flex-shrink: 0; }
.record-main { flex: 1; min-width: 0; }
@media (max-width: 900px) {
  .record-layout { flex-direction: column; }
  .record-sidebar { width: 100%; }
}

/* ---------- Modal ---------- */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(17,17,17,.5); z-index: 1000;
  align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); max-width: 780px; width: 100%; max-height: 92vh; overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 20px;
  background: var(--brand-black); color: #fff; border-radius: var(--radius) var(--radius) 0 0;
}
.modal-header h3 { color: #fff; font-size: 16px; margin: 0; }
.modal-header .close-x { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Kanban (Pipeline) ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kanban-col { background: var(--gray-100); border-radius: var(--radius); width: 250px; flex-shrink: 0; padding: 10px; min-height: 100px; }
.kanban-col h4 { font-size: 12.5px; text-transform: uppercase; color: var(--gray-700); display: flex; justify-content: space-between; margin-bottom: 10px; }
.kanban-col h4 .count { background: #fff; border-radius: 10px; padding: 1px 8px; font-size: 11px; }
.kanban-card {
  background: #fff; border-radius: 8px; box-shadow: var(--shadow); padding: 10px 12px; margin-bottom: 8px;
  cursor: grab; border-left: 4px solid var(--brand-red); font-size: 13px;
}
.kanban-card.dragging { opacity: .4; }
.kanban-card .name { font-weight: 700; margin-bottom: 2px; }
.kanban-card .meta { color: var(--gray-500); font-size: 11.5px; }
.kanban-col.drop-target { outline: 2px dashed var(--brand-red); }

/* ---------- Calendar ---------- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); border: 1px solid var(--gray-200); background: #fff; border-radius: var(--radius); overflow: hidden; }
.calendar-grid .cal-head { background: var(--gray-50); padding: 8px; text-align: center; font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--gray-200); }
.calendar-grid .cal-day { border-right: 1px solid var(--gray-200); border-bottom: 1px solid var(--gray-200); min-height: 110px; padding: 6px; position: relative; }
.calendar-grid .cal-day .daynum { font-size: 12px; color: var(--gray-500); font-weight: 700; }
.calendar-grid .cal-day.today { background: #fff5f5; }
.cal-appt { display: block; background: var(--blue); color: #fff; border-radius: 4px; padding: 2px 5px; font-size: 11px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.cal-appt:hover { opacity: .85; text-decoration: none; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--gray-50); padding: 20px; }
.login-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px 32px; width: 100%; max-width: 380px; text-align: center; }
.login-box img { height: 60px; margin-bottom: 18px; }
.login-box .btn-primary { width: 100%; padding: 11px; font-size: 15px; margin-top: 6px; }

/* ---------- Misc ---------- */
.text-muted { color: var(--gray-500); }
.text-right { text-align: right; }
.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error { background: #fde8e8; color: #9b1c1c; }
.empty-state { text-align: center; padding: 50px 20px; color: var(--gray-500); }
.footer-note { text-align: center; padding: 20px; color: var(--gray-500); font-size: 12px; }
hr { border: none; border-top: 1px solid var(--gray-200); margin: 16px 0; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.gap-sm { display: flex; gap: 8px; flex-wrap: wrap; }
