/* =========================================================================
   COUNSELION PREMIUM ADMIN DASHBOARD - UI SYSTEM
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Urbanist:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #006B44;
  --primary-dark: #01422D;
  --accent: #D4A64A;
  --accent-light: #E8C67A;
  
  --bg-main: #fdfdfa;
  --bg-card: #ffffff;
  --bg-hover: #f4f4ec;
  
  --text-dark: #1A1D1E;
  --text-muted: #575959;
  --text-light: #a0a0a0;
  
  --border-color: rgba(1, 66, 45, 0.12);
  --border-light: rgba(1, 66, 45, 0.06);
  
  --shadow-sm: 0 4px 12px rgba(1, 66, 45, 0.03);
  --shadow-md: 0 12px 30px rgba(1, 66, 45, 0.06);
  --shadow-lg: 0 24px 60px rgba(1, 66, 45, 0.1);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  --font-main: 'Urbanist', sans-serif;
  
  --sidebar-width: 280px;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-main);
  color: var(--text-dark);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden; /* App-like feel */
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* =========================================================================
   UTILITIES
   ========================================================================= */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; } .gap-8 { gap: 32px; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }

/* Typography */
.text-xs { font-size: 12px; }
.text-sm { font-size: 14px; }
.text-base { font-size: 15px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 22px; }
.text-2xl { font-size: 28px; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.text-primary { color: var(--primary); }
.text-dark { color: var(--primary-dark); }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-white { color: #fff; }

/* =========================================================================
   BUTTONS & BADGES
   ========================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  transition: all 0.2s ease;
}
.btn-primary { background: var(--primary-dark); color: #fff; }
.btn-primary:hover { background: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #b88b2a; }
.btn-outline { border: 1px solid var(--border-color); color: var(--primary-dark); background: transparent; }
.btn-outline:hover { background: var(--bg-hover); }
.btn-ghost { color: var(--text-muted); padding: 8px 12px; }
.btn-ghost:hover { color: var(--primary-dark); background: rgba(1,66,45,0.05); }

.badge {
  padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-new { background: rgba(212, 166, 74, 0.15); color: #b88b2a; }
.badge-review { background: rgba(0, 107, 68, 0.1); color: var(--primary); }
.badge-scheduled { background: rgba(1, 66, 45, 0.1); color: var(--primary-dark); }
.badge-completed { background: #f0f0f0; color: var(--text-muted); }

/* =========================================================================
   LOGIN SCREEN
   ========================================================================= */
#login-view {
  position: fixed; inset: 0; background: var(--bg-main); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: #fff; width: 100%; max-width: 440px; padding: 50px;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-light);
}
.login-logo { text-align: center; margin-bottom: 40px; }
.login-logo img { height: 40px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control {
  width: 100%; padding: 14px 16px; border: 1px solid var(--border-color); border-radius: var(--radius-sm);
  font-size: 15px; color: var(--text-dark); transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: #fafafa;
}
.form-control:focus { outline: none; border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(212, 166, 74, 0.1); }

/* =========================================================================
   APP LAYOUT (SIDEBAR + MAIN)
   ========================================================================= */
.app-container { display: flex; height: 100vh; width: 100vw; overflow: hidden; display: none; }
.app-container.active { display: flex; }

.sidebar {
  width: var(--sidebar-width); background: var(--primary-dark); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
  border-right: 1px solid rgba(255,255,255,0.05); position: relative;
}
.sidebar-logo { padding: 30px; border-bottom: 1px solid rgba(255,255,255,0.05); }
.sidebar-logo img { height: 32px; filter: brightness(0) invert(1); }
.sidebar-nav { padding: 24px 16px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 4px;
  color: rgba(255,255,255,0.6); border-radius: var(--radius-sm); font-weight: 500;
  transition: all 0.2s ease; cursor: pointer;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-item.active { color: var(--accent); background: rgba(212, 166, 74, 0.1); font-weight: 600; }
.nav-item i { font-size: 18px; width: 24px; text-align: center; }

.sidebar-user { padding: 24px 20px; border-top: 1px solid rgba(255,255,255,0.05); display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }

.main-content {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg-main);
}
.topbar {
  height: 72px; padding: 0 40px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-color); background: #fff; flex-shrink: 0;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--primary-dark); }
.topbar-actions { display: flex; align-items: center; gap: 16px; }

.content-area { flex: 1; overflow-y: auto; padding: 40px; }

/* View Management */
.view-section { display: none; animation: fadeIn 0.3s ease; }
.view-section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================================
   CARDS & PANELS
   ========================================================================= */
.card {
  background: var(--bg-card); border-radius: var(--radius-md); border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.card-title { font-size: 16px; font-weight: 700; color: var(--primary-dark); }
.card-body { padding: 24px; }

.stat-card { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-value { font-size: 32px; font-family: var(--font-heading); font-weight: 700; color: var(--primary-dark); line-height: 1; }
.stat-trend { font-size: 13px; font-weight: 500; color: var(--primary); display: flex; align-items: center; gap: 4px; }

/* =========================================================================
   TABLES
   ========================================================================= */
.table-wrapper { width: 100%; overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left; padding: 16px 24px; font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border-color);
  background: #fafafa;
}
.admin-table td {
  padding: 16px 24px; border-bottom: 1px solid var(--border-light); font-size: 14px; color: var(--text-dark);
  vertical-align: middle; transition: background 0.2s ease;
}
.admin-table tbody tr:hover td { background: var(--bg-hover); cursor: pointer; }
.admin-table tbody tr:last-child td { border-bottom: none; }

.td-user { display: flex; align-items: center; gap: 12px; }
.td-user-initial { width: 32px; height: 32px; border-radius: 50%; background: rgba(1,66,45,0.05); color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.td-user-info strong { display: block; font-weight: 600; margin-bottom: 2px; }
.td-user-info span { color: var(--text-muted); font-size: 13px; }

/* =========================================================================
   SUBMISSION DETAILS (SPLIT VIEW)
   ========================================================================= */
.detail-layout { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }
.detail-section { margin-bottom: 30px; }
.detail-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.detail-value { font-size: 15px; color: var(--text-dark); background: #fafafa; padding: 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-light); }

.timeline { position: relative; padding-left: 20px; margin-top: 20px; }
.timeline::before { content: ''; position: absolute; left: 4px; top: 0; bottom: 0; width: 2px; background: var(--border-color); }
.timeline-item { position: relative; margin-bottom: 24px; }
.timeline-item::before { content: ''; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px #fff; }
.timeline-time { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.timeline-content { font-size: 14px; font-weight: 500; }

.note-input { background: #fafafa; border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 16px; margin-top: 20px; }
.note-input textarea { width: 100%; border: none; background: transparent; resize: vertical; min-height: 80px; outline: none; font-size: 14px; }
.note-actions { display: flex; justify-content: flex-end; margin-top: 12px; }

/* =========================================================================
   EMAIL MANAGEMENT (RICH UI)
   ========================================================================= */
.email-editor { border: 1px solid var(--border-color); border-radius: var(--radius-sm); overflow: hidden; }
.editor-toolbar { padding: 12px 16px; background: #fafafa; border-bottom: 1px solid var(--border-color); display: flex; gap: 12px; }
.editor-toolbar button { padding: 6px 10px; color: var(--text-muted); border-radius: 4px; }
.editor-toolbar button:hover { background: rgba(1,66,45,0.05); color: var(--primary-dark); }
.editor-body { padding: 24px; min-height: 300px; outline: none; font-size: 15px; line-height: 1.8; }
.editor-placeholder { display: inline-block; background: rgba(212, 166, 74, 0.15); color: #b88b2a; padding: 2px 6px; border-radius: 4px; font-size: 13px; font-family: monospace; }

.email-preview-wrapper { background: #f0f0f0; padding: 40px; border-radius: var(--radius-sm); display: flex; justify-content: center; }
.email-preview-card { background: #fff; width: 100%; max-width: 600px; border-radius: 8px; box-shadow: var(--shadow-md); overflow: hidden; }
.email-preview-header { padding: 30px; text-align: center; border-bottom: 1px solid var(--border-light); }
.email-preview-header img { height: 30px; }
.email-preview-body { padding: 40px; font-size: 15px; line-height: 1.6; color: var(--text-dark); }

/* =========================================================================
   PHP ADMIN COMPATIBILITY
   Keeps dynamic backend pages native to the original admin.html UI system.
   ========================================================================= */
.admin-alert,
.alert {
  padding: 14px 16px;
  margin-bottom: 20px;
  border: 1px solid rgba(212, 166, 74, 0.25);
  border-radius: var(--radius-sm);
  background: rgba(212, 166, 74, 0.12);
  color: var(--primary-dark);
  font-weight: 600;
}
.admin-alert.error,
.alert.error {
  border-color: rgba(180, 48, 48, 0.2);
  background: rgba(180, 48, 48, 0.08);
  color: #8a2424;
}
.panel { padding: 24px; }
.panel-head,
.searchbar,
.filter-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}
.searchbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px auto;
}
.searchbar input,
.searchbar select,
.field input,
.field select,
.field textarea,
.user-row-form input,
.user-row-form select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fafafa;
  color: var(--text-dark);
  font-size: 14px;
}
.field { margin-bottom: 18px; }
.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.field textarea { min-height: 150px; resize: vertical; }
.status { display: inline-flex; }
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.6fr);
  gap: 24px;
  align-items: start;
}
.info-list { display: grid; gap: 16px; }
.info-item span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.info-item strong,
.info-item p {
  display: block;
  margin: 0;
  color: var(--text-dark);
  background: #fafafa;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  line-height: 1.7;
}
.note {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}
.note p { margin-top: 6px; color: var(--text-muted); }
.template-card { margin-bottom: 24px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.user-row-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.65fr) auto minmax(170px, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.checkline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--primary-dark);
  font-weight: 700;
  white-space: nowrap;
}
.admin-table a.btn,
.info-item a.btn { text-decoration: none; }

/* CMS editorial workspace */
.cms-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 24px;
  align-items: start;
}
.cms-editor-main { display: grid; gap: 24px; min-width: 0; }
.cms-editor-side { display: grid; gap: 24px; min-width: 0; }
.cms-sticky-panel { position: sticky; top: 0; }
.cms-section-gap { margin-top: 24px; }
.cms-field-grid { display: grid; gap: 18px; }
.cms-field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cms-field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field small {
  display: block;
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}
.field .cms-long-editor { min-height: 360px; line-height: 1.7; }
.cms-repeat-section { overflow: visible; }
.cms-repeat-list { display: grid; gap: 12px; }
.cms-repeat-row {
  display: grid;
  grid-template-columns: 24px minmax(220px, 1fr) minmax(190px, .55fr) 42px;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: #fafafa;
}
.cms-repeat-row textarea,
.cms-repeat-row input {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  resize: vertical;
}
.cms-drag-handle { padding-top: 12px; color: var(--text-light); text-align: center; }
.cms-repeat-row[draggable="true"] .cms-drag-handle { cursor: grab; }
.cms-repeat-row.is-dragging { opacity: .5; border-color: var(--accent); }
.cms-danger { color: #9f2d2d; }
.cms-danger:hover { color: #7d1717; background: rgba(159, 45, 45, .08); }
.cms-publish-actions { display: grid; gap: 10px; margin-top: 22px; }
.cms-check { margin: 8px 0 16px; }
.cms-check input { width: 17px; height: 17px; accent-color: var(--primary); }
.cms-image-preview {
  width: 100%;
  max-height: 360px;
  margin: 14px 0 18px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}
.cms-image-empty {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  margin: 14px 0 18px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: #fafafa;
}
.cms-image-empty i { font-size: 30px; color: var(--accent); }
.cms-person-cell { display: flex; align-items: center; gap: 12px; min-width: 230px; }
.cms-person-cell img,
.cms-avatar-placeholder {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(1, 66, 45, .08);
}
.cms-avatar-placeholder { display: grid; place-items: center; color: var(--primary-dark); font-weight: 800; }
.cms-person-cell strong,
.cms-person-cell small { display: block; }
.cms-person-cell small { margin-top: 2px; color: var(--text-muted); }
.cms-row-actions { display: flex; align-items: center; gap: 4px; }
.cms-row-actions form { margin: 0; }
.cms-empty { padding: 36px; color: var(--text-muted); text-align: center; }
.cms-favicon-row { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 18px; align-items: start; }
.cms-favicon-row img { width: 64px; height: 64px; padding: 8px; object-fit: contain; border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: #fff; }
.cms-inline-checks { display: flex; flex-wrap: wrap; gap: 28px; margin-bottom: 18px; }
.cms-divider { height: 1px; margin: 28px 0; border: 0; background: var(--border-color); }
.cms-code-editor { font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; tab-size: 2; }
.cms-counter { float: right; color: var(--accent); font-weight: 600; letter-spacing: 0; text-transform: none; }
.cms-og-preview { display: grid; grid-template-columns: minmax(0, 260px) 1fr; gap: 18px; align-items: center; margin-bottom: 20px; }
.cms-og-preview img { width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; border-radius: var(--radius-sm); }
.cms-page-list { display: grid; gap: 8px; margin: 16px 0 22px; }
.cms-page-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; border: 1px solid var(--border-light); border-radius: var(--radius-sm); transition: .2s ease; }
.cms-page-link:hover,
.cms-page-link.active { border-color: rgba(212, 166, 74, .6); background: rgba(212, 166, 74, .08); }
.cms-page-link strong,
.cms-page-link small { display: block; }
.cms-page-link small { color: var(--text-muted); }

@media (max-width: 1100px) {
  .grid-4,
  .grid-3,
  .grid-2,
  .detail-grid,
  .settings-grid,
  .cms-editor-layout,
  .cms-field-grid.three { grid-template-columns: 1fr; }
  .cms-sticky-panel { position: static; }
  .searchbar,
  .user-row-form { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .cms-field-grid.two,
  .cms-repeat-row { grid-template-columns: 1fr; }
  .cms-drag-handle { display: none; }
  .cms-repeat-row .cms-danger { justify-self: end; }
  .cms-og-preview { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .app-container.active { min-height: 100vh; height: auto; flex-direction: column; overflow: visible; }
  .sidebar { width: 100%; min-height: auto; }
  .sidebar-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-content { overflow: visible; }
  .content-area { padding: 24px; overflow: visible; }
  .topbar { height: auto; padding: 20px 24px; align-items: flex-start; gap: 16px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
}
