/* ============================================================
   LCAP Manager - Main Stylesheet
   Simi Valley USD
   ============================================================ */

:root {
  --primary:       #1a3a5c;
  --primary-light: #1a6faf;
  --primary-dark:  #0d2338;
  --accent:        #e8a020;
  --accent-dark:   #c07010;
  --bg:            #f4f6f9;
  --card-bg:       #ffffff;
  --text:          #1c2938;
  --text-muted:    #6c757d;
  --border:        #dee2e6;
  --success:       #2e7d32;
  --warning:       #f9a825;
  --danger:        #c62828;
  --info:          #01579b;

  --goal-l1:       #1a6faf;
  --goal-l2:       #2e7d32;
  --goal-l3:       #7b1fa2;
  --goal-l4:       #e65100;
  --goal-l5:       #00695c;

  --sidebar-w:     260px;
  --topbar-h:      60px;
  --radius:        6px;
  --shadow:        0 1px 4px rgba(0,0,0,.12);
  --shadow-md:     0 3px 10px rgba(0,0,0,.14);
}

/* ── Reset & Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ───────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--primary-dark);
  color: #fff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: width .25s;
}

#main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

#content {
  flex: 1;
  padding: 1.5rem;
}

/* ── Sidebar Brand ────────────────────────────────────────────── */
.sidebar-brand {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand h1 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
}
.sidebar-brand p {
  font-size: .72rem;
  color: rgba(255,255,255,.6);
  margin-top: 2px;
}

/* ── Sidebar Nav ──────────────────────────────────────────────── */
.sidebar-nav { padding: .75rem 0; flex: 1; }
.nav-section-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.4);
  padding: .9rem 1.25rem .3rem;
  font-weight: 600;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem 1.25rem;
  color: rgba(255,255,255,.8);
  font-size: .88rem;
  transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
  border-left-color: var(--accent);
}
.sidebar-nav a svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.sidebar-nav a:hover svg, .sidebar-nav a.active svg { opacity: 1; }

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--primary);
  flex: 1;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .85rem;
  color: var(--text-muted);
}
.topbar-user strong { color: var(--text); }
.topbar-user a { color: var(--danger); font-size: .8rem; }

/* ── Page Header ──────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  flex: 1;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}
.card-header {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .92rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(0,0,0,.02);
  border-radius: var(--radius) var(--radius) 0 0;
}
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,.02);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ── Stat Cards (Dashboard) ───────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--primary-light);
  display: flex;
  flex-direction: column;
  gap: .25rem;
}
.stat-card .stat-label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  font-weight: 600;
}
.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}
.stat-card .stat-sub { font-size: .78rem; color: var(--text-muted); }
.stat-card.goal-l1 { border-left-color: var(--goal-l1); }
.stat-card.goal-l2 { border-left-color: var(--goal-l2); }
.stat-card.goal-l3 { border-left-color: var(--goal-l3); }
.stat-card.goal-l4 { border-left-color: var(--goal-l4); }
.stat-card.goal-l5 { border-left-color: var(--goal-l5); }
.stat-card.success  { border-left-color: var(--success); }
.stat-card.warning  { border-left-color: var(--warning); }
.stat-card.danger   { border-left-color: var(--danger); }

/* ── Tables ───────────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .87rem;
}
.data-table th {
  background: var(--primary);
  color: #fff;
  padding: .65rem .9rem;
  text-align: left;
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.data-table td {
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f0f4f8; }
.data-table td.money { text-align: right; font-family: monospace; font-size: .85rem; }
.data-table td.center { text-align: center; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2em .6em;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .3px;
  white-space: nowrap;
}
.badge-success  { background: #e8f5e9; color: var(--success); }
.badge-warning  { background: #fff8e1; color: #e65100; }
.badge-danger   { background: #ffebee; color: var(--danger); }
.badge-info     { background: #e3f2fd; color: var(--info); }
.badge-secondary{ background: #eceff1; color: #546e7a; }
.badge-primary  { background: #e3f2fd; color: var(--primary); }

.goal-badge {
  display: inline-block;
  padding: .2em .7em;
  border-radius: 4px;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; text-decoration: none; }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #1b5e20; color: #fff; text-decoration: none; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #b71c1c; color: #fff; text-decoration: none; }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm { padding: .3rem .65rem; font-size: .78rem; }
.btn-icon { padding: .35rem .45rem; }

/* ── Forms ────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  margin-bottom: .35rem;
  color: var(--text);
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid #adb5bd;
  border-radius: var(--radius);
  font-size: .88rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(26,111,175,.15);
}

/* Ensure all editable inputs/selects/textareas always show a visible border */
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
select,
textarea {
  border: 1px solid #adb5bd !important;
  border-radius: var(--radius);
  background: #fff;
}
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary-light) !important;
  box-shadow: 0 0 0 3px rgba(26,111,175,.15);
  outline: none;
}
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { padding-right: 2rem; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c757d' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; }
.form-text { font-size: .75rem; color: var(--text-muted); margin-top: .25rem; }
.form-check { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.form-check input[type=checkbox] { width: 1rem; height: 1rem; cursor: pointer; }

/* Form grid */
.form-row { display: grid; gap: 1rem; }
.form-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Alerts ───────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .88rem;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: .65rem;
}
.alert-success { background: #e8f5e9; border-color: #a5d6a7; color: #1b5e20; }
.alert-error, .alert-danger { background: #ffebee; border-color: #ef9a9a; color: #b71c1c; }
.alert-warning { background: #fff8e1; border-color: #ffe082; color: #e65100; }
.alert-info    { background: #e3f2fd; border-color: #90caf9; color: #01579b; }

/* ── Progress Bar ─────────────────────────────────────────────── */
.progress-bar-wrap {
  background: #e0e0e0;
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  border-radius: 20px;
  background: var(--primary-light);
  transition: width .4s;
}
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }

/* ── Pagination ───────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: .3rem;
  flex-wrap: wrap;
  font-size: .85rem;
}
.pagination a, .pagination span {
  padding: .3rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.pagination a:hover { background: var(--bg); text-decoration: none; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Filter Bar ───────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filter-bar .form-control { width: auto; }
.search-input { min-width: 220px; }

/* ── Login Page ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}
.login-card {
  background: #fff;
  border-radius: 10px;
  padding: 2.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.login-card .login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-card h2 {
  font-size: 1.3rem;
  color: var(--primary);
  text-align: center;
  margin-bottom: .25rem;
}
.login-card p.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: .82rem;
  margin-bottom: 1.5rem;
}

/* ── Dashboard Charts Placeholder ────────────────────────────── */
.chart-container { position: relative; height: 260px; }

/* ── Goal Color Utilities ─────────────────────────────────────── */
.text-goal-l1 { color: var(--goal-l1); }
.text-goal-l2 { color: var(--goal-l2); }
.text-goal-l3 { color: var(--goal-l3); }
.text-goal-l4 { color: var(--goal-l4); }
.text-goal-l5 { color: var(--goal-l5); }

/* ── Utilities ────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.fw-bold { font-weight: 700; }
.small { font-size: .82rem; }
.nowrap { white-space: nowrap; }
.upp-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .15em .55em;
  border-radius: 4px;
  background: #fff3e0;
  color: #e65100;
  font-size: .7rem;
  font-weight: 700;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-wrap { margin-left: 0; }
  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ── Print ────────────────────────────────────────────────────── */
@media print {
  #sidebar, #topbar, .no-print { display: none !important; }
  #main-wrap { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── Autosave status badge ────────────────────────────────────── */
.autosave-badge {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  padding: .3rem .9rem;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
  z-index: 9000;
  box-shadow: 0 1px 6px rgba(0,0,0,.18);
  white-space: nowrap;
}
.autosave-idle    { opacity: 0 !important; }
.autosave-saving  { opacity: 1; background: #fff8e1; color: #e65100; border: 1px solid #ffe082; }
.autosave-saved   { opacity: 1; background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.autosave-error   { opacity: 1; background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }

/* ── Quill Rich-Text Editor ───────────────────────────────────── */
.ql-toolbar.ql-snow {
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  background: #f8fafc;
  padding: .25rem .5rem;
  font-family: inherit;
}
.ql-container.ql-snow {
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: inherit;
  font-size: .9375rem;
}
.ql-editor {
  min-height: 80px;
  padding: .45rem .75rem;
  line-height: 1.55;
}
.ql-editor.ql-blank::before {
  font-style: normal;
  color: var(--text-muted);
}
.ql-editor p    { margin: 0 0 .35em; }
.ql-editor p:last-child { margin-bottom: 0; }
.ql-editor ul, .ql-editor ol { padding-left: 1.5em; margin: .25em 0; }

/* Rich-text output (view/display mode) */
.rich-content p  { margin: 0 0 .4em; }
.rich-content p:last-child { margin-bottom: 0; }
.rich-content ul, .rich-content ol { padding-left: 1.5em; margin: .25em 0; }
