/*
 * Main shared stylesheet
 * Base styles used across public pages and both dashboards
 */

/* CSS Variables */
:root {
  --brand: #1f6feb;
  --muted: #6b7280;
  --bg: #f8fafc;
  --dark: #0f1724;
  --accent: #0ea5a4;
  --success: #2e7d32;
  --warning: #f59e0b;
  --danger: #dc2626;
}

/* Basic reset */
* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  margin: 0;
  color: var(--dark);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

/* Container */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin: 0;
  line-height: 1.2;
}

p {
  margin: 0 0 1rem;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Header / Navigation */
.site-header {
  background: #fff;
  border-bottom: 1px solid #e6edf3;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 40px;
  padding: 14px 0;
}

/* Profile Dropdown Styles for Public Pages */
.user-profile-nav {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
}

.profile-avatar-nav {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.profile-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 8px;
  z-index: 1001;
  border: 1px solid #e2e8f0;
  animation: dropdownFadeIn 0.2s ease-out;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.profile-dropdown-menu.show {
  display: block;
}

.profile-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--dark);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
}

.profile-dropdown-item:hover {
  background-color: #f1f5f9;
  color: var(--brand);
}

.profile-dropdown-item i {
    font-size: 18px;
    color: var(--muted);
    transition: color 0.2s;
}

.profile-dropdown-item:hover i {
    color: var(--brand);
}

.profile-dropdown-divider {
  height: 1px;
  background-color: #e2e8f0;
  margin: 8px 0;
}

.text-danger {
  color: #dc2626 !important;
}

.profile-dropdown-item.text-danger:hover {
    background-color: #fee2e2;
    color: #dc2626;
}
.profile-dropdown-item.text-danger:hover i {
    color: #dc2626;
}

/* Profile Name in Nav */
.profile-name-nav {
    font-weight: 600;
    font-size: 14px;
    color: var(--dark);
}

.brand {
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
  font-size: 1.25rem;
}

.site-nav {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: space-between;
}

.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 12px;
  align-items: center;
}

.site-nav a {
  color: var(--dark);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 6px;
}

.site-nav a:hover {
  background: #f1f5f9;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  color: var(--dark);
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
  cursor: pointer;
  border: none;
  font-size: 14px;
}

.btn:focus {
  outline: 2px solid rgba(31, 111, 235, 0.18);
  outline-offset: 2px;
}

.btn-outline {
  border: 1px solid #e2e8f0;
  background: transparent;
  color: var(--dark);
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 20px rgba(31, 111, 235, 0.08);
}

.btn:hover {
  transform: translateY(-3px);
}

.btn-primary:hover {
  box-shadow: 0 14px 32px rgba(31, 111, 235, 0.12);
}

.btn-full {
  width: 100%;
}

.button, input[type="submit"] {
  background: var(--brand);
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.button:hover, input[type="submit"]:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

/* Forms */
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--brand);
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.1);
}

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--dark);
}

select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(12, 20, 30, 0.04);
  padding: 24px;
  border: 1px solid #e6edf3;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(12, 20, 30, 0.04);
}

thead {
  background: #f8fafc;
  border-bottom: 2px solid #e6edf3;
}

th {
  padding: 14px;
  text-align: left;
  font-weight: 700;
  color: var(--dark);
}

td {
  padding: 14px;
  border-bottom: 1px solid #e6edf3;
  color: var(--muted);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: #f8fafc;
}

/* Hero sections */
.hero {
  padding: 48px 0 32px;
  text-align: center;
}

.hero .lead {
  color: var(--muted);
  max-width: 700px;
  margin: 12px auto;
}

.page-center {
  padding: 48px 0;
  text-align: center;
}

/* Flash messages / Alerts */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-weight: 500;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
  border-left: 4px solid #10b981;
}

.alert-error, .alert-danger {
  background: #fee2e2;
  color: #991b1b;
  border-left: 4px solid #ef4444;
}

.alert-info {
  background: #dbeafe;
  color: #1e40af;
  border-left: 4px solid #3b82f6;
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
  border-left: 4px solid #f59e0b;
}

/* ===== Dashboard Shell Redesign ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* Sidebar: sticky column that sits flush with content */
.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 280px; /* expanded width */
  flex: 0 0 auto;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
}

/* Collapsed state (preserved by existing JS on .app-shell) */
.app-shell.sidebar-collapsed .app-sidebar {
  width: 72px; /* collapsed width */
}

/* Sidebar sections */
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-brand {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.sidebar-toggle {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.2); }
.toggle-icon { font-size: 18px; font-weight: 800; }

.sidebar-nav { padding: 10px 8px; flex: 1 1 auto; }
.sidebar-bottom { padding: 10px 8px; border-top: 1px solid rgba(255,255,255,0.06); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: rgba(255,255,255,0.92);
  transition: background 0.18s ease, color 0.18s ease, padding 0.25s ease;
}
.nav-item:hover { background: var(--sidebar-hover); }
.nav-item.logout { color: #ffdbd6; }

.nav-icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; }
.nav-label { white-space: nowrap; transition: opacity 0.2s ease, width 0.25s ease; }

/* Hide text labels when collapsed, keep icons centered */
.app-shell.sidebar-collapsed .nav-label,
.app-shell.sidebar-collapsed .sidebar-brand { opacity: 0; visibility: hidden; width: 0; overflow: hidden; }
.app-shell.sidebar-collapsed .nav-item { justify-content: center; padding-left: 12px; padding-right: 12px; }

/* ===== Main area: flush with sidebar, responsive grid ===== */
.app-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  background: #fff;
  border-bottom: 1px solid #e6edf3;
  transition: border-color 0.25s ease;
}

.topbar-inner { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; }
.profile-circle { width: 36px; height: 36px; border-radius: 50%; background: #e6edf3; color: var(--dark); display: flex; align-items: center; justify-content: center; font-weight: 700; }

/* Content area: remove default container left padding so it touches the sidebar */
.app-main .container { max-width: 1200px; padding-left: 16px; padding-right: 16px; }

/* For auth dashboards, remove left padding completely to visually merge with sidebar */
.auth-main-content.container { padding-left: 0 !important; padding-right: 16px; }

/* Card polish */
.card { border: 1px solid #e6edf3; }

/* Dashboard stats grid */
.dashboard-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* Mobile handling */
@media (max-width: 992px) {
  .app-shell.sidebar-collapsed .app-sidebar { flex-basis: 64px; }
}
@media (max-width: 768px) {
  .app-sidebar { position: fixed; z-index: 1000; left: 0; right: auto; transform: translateX(0); transition: transform 0.25s ease, width 0.25s ease; }
  .app-shell.sidebar-collapsed .app-sidebar { transform: translateX(-100%); }
  .app-main .container, .auth-main-content.container { padding-left: 16px !important; }
}

/* Utility classes */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--muted);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }
.p-4 { padding: 2rem; }

.d-flex {
  display: flex;
}

.align-items-center {
  align-items: center;
}

.justify-content-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 1rem;
}

/* Safety: ensure dev notice modal never displays if present */
#devNoticeModal { display: none !important; }
