/* ===== CSS Custom Properties ===== */
:root {
  --bg:            #F8F7F4;
  --surface:       #FFFFFF;
  --text:          #1A1A1A;
  --text-muted:    #6B6B6B;
  --text-faint:    #A8A5A0;
  --accent:        #2D5BE3;
  --accent-hover:  #2248C7;
  --accent2:       #E3632D;
  --accent2-hover: #C75523;
  --border:        #E8E5E0;
  --border-focus:  #2D5BE3;
  --danger:        #E35A2D;
  --success:       #2D9E5B;

  --font-serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --font-sans:  'Geist', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --sidebar-w:  220px;
  --radius:     8px;
  --radius-sm:  5px;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.06);
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
  --transition: 0.15s ease;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button { cursor: pointer; }

img { display: block; max-width: 100%; }

/* ===== Typography ===== */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -0.02em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

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

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.875rem;
  z-index: 50;
}

.sidebar-logo {
  font-family: var(--font-serif);
  font-size: 1.375rem;
  color: var(--text);
  padding: 0.25rem 0.5rem;
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
  display: block;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5625rem;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.nav-item:hover          { background: var(--bg); color: var(--text); }
.nav-item.active         { background: var(--bg); color: var(--accent); }
.nav-item.active svg     { color: var(--accent); }
.nav-item svg            { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding-top: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-block {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-sm);
}

.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar.sonya { background: var(--accent2); }

.user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

/* ===== Main Content ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2.5rem 2.5rem;
  min-height: 100vh;
}

/* ===== Mobile Header ===== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
}

.mobile-logo {
  font-family: var(--font-serif);
  font-size: 1.25rem;
}

.mobile-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===== Mobile Bottom Nav ===== */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.5rem 0 calc(0.5rem + env(safe-area-inset-bottom));
  z-index: 50;
}

.mobile-nav-items {
  display: flex;
  justify-content: space-around;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 0.375rem 0.875rem;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.mobile-nav-item.active  { color: var(--accent); }
.mobile-nav-item svg     { width: 20px; height: 20px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  outline: none;
  transition: background var(--transition), opacity var(--transition), box-shadow var(--transition);
  line-height: 1;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover  { background: var(--accent-hover); }
.btn-primary:active { opacity: .9; }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm  { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg  { padding: 0.75rem 1.25rem; font-size: 0.9375rem; }
.btn-block { width: 100%; }

/* ===== Forms ===== */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-input {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9375rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(45, 91, 227, 0.12);
}
.form-input::placeholder { color: var(--text-faint); }

/* ===== Alerts ===== */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.4;
}
.alert-error {
  background: #FEF2EE;
  color: #C04A1F;
  border: 1px solid #F8C9B7;
}
.alert-success {
  background: #EDFAF3;
  color: #1E7A43;
  border: 1px solid #A8E6C0;
}

/* ===== Cards ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* ===== Page Header ===== */
.page-header { margin-bottom: 2rem; }

.page-title {
  font-family: var(--font-serif);
  font-size: 1.75rem;
  letter-spacing: -0.025em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ===== Dashboard — Module Grid ===== */
.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.75rem;
}

.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  text-decoration: none;
  color: inherit;
}
.module-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #D4D0CC;
  transform: translateY(-1px);
}

.module-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.module-icon svg { width: 20px; height: 20px; }

.module-icon-blue   { background: rgba(45,91,227,.1);  color: var(--accent); }
.module-icon-orange { background: rgba(227,99,45,.1);  color: var(--accent2); }
.module-icon-teal   { background: rgba(45,158,91,.1);  color: var(--success); }

.module-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.module-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
}

/* ===== Notification Bell ===== */
.notif-bell {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  padding: 0.5rem 0.625rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  width: 100%;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.notif-bell:hover { background: var(--bg); color: var(--text); }
.notif-bell-mobile {
  width: auto;
  padding: 0.375rem;
  color: var(--text-muted);
}

.notif-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  border-radius: 99px;
  line-height: 1;
}

/* ===== Notification Panel ===== */
.notif-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 320px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 20px rgba(0,0,0,.08);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.2s ease;
}
.notif-panel.open { transform: translateX(0); }

.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.notif-panel-title {
  font-family: var(--font-serif);
  font-size: 1.125rem;
}

.notif-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.notif-item {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 0.375rem;
  background: var(--bg);
}

.notif-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.notif-item-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.notif-read-btn {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 1px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.notif-read-btn:hover { color: var(--success); }

.notif-item-body {
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.notif-item-time {
  font-size: 0.75rem;
  color: var(--text-faint);
}

/* ===== Notification Badge (legacy dot) ===== */
.notif-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .notif-panel { width: 100%; top: 52px; }
}

/* ===== Divider ===== */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}

.login-heading {
  font-family: var(--font-serif);
  font-size: 2rem;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.375rem;
}

.login-subheading {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar        { display: none; }
  .mobile-header  { display: flex; }
  .mobile-nav     { display: block; }

  .main-content {
    margin-left: 0;
    padding: 1.25rem 1rem;
    padding-top: calc(52px + 1.25rem);
    padding-bottom: calc(60px + 1.25rem + env(safe-area-inset-bottom));
  }

  .module-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 200px; }
  .main-content { padding: 2rem 1.5rem; }
}
