/* ============================================================
   Atera Central CMS — Main Layout & Variables
   ============================================================ */

:root {
  /* Brand Colors */
  --color-primary:       #7B3525;
  --color-primary-dark:  #5C2819;
  --color-primary-light: #A0503C;
  --color-gold:          #C9A96E;
  --color-gold-light:    #DFC090;
  --color-gold-faint:    #F5EDE0;

  /* Surface */
  --color-bg:            #FAFAF8;
  --color-surface:       #FFFFFF;
  --color-surface-2:     #F7F2EE;

  /* Text */
  --color-text:          #1A1208;
  --color-text-muted:    #6B5B4E;
  --color-text-light:    #9E8878;

  /* Borders */
  --color-border:        #E5D5C8;
  --color-border-strong: #C9B5A7;

  /* Status */
  --status-waiting-dir:   #F97316;
  --status-waiting-chair: #F97316;
  --status-waiting-ext:   #3B82F6;
  --status-signed:        #22C55E;
  --status-cancelled:     #EF4444;
  --status-expired:       #9CA3AF;

  /* Semantic */
  --color-success:       #22C55E;
  --color-warning:       #F59E0B;
  --color-danger:        #EF4444;
  --color-info:          #3B82F6;

  /* Layout */
  --sidebar-width:       240px;
  --sidebar-collapsed:   64px;
  --topbar-height:       60px;
  --border-radius:       8px;
  --border-radius-lg:    12px;
  --shadow-sm:           0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:           0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:           0 8px 24px rgba(0,0,0,0.12);

  /* Typography */
  --font-sans: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); }
img { max-width: 100%; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

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

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width 0.25s ease;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  height: var(--topbar-height);
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(10);
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-logo-text .brand-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.sidebar-logo-text .brand-sub {
  font-size: 0.65rem;
  color: var(--color-gold-light);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  color: rgba(255,255,255,0.82);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.10);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-left-color: var(--color-gold);
}

.sidebar-nav a .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-section-label {
  padding: 12px 18px 4px;
  font-size: 0.68rem;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,0.12);
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
}

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-title {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
}

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

.topbar-user-role {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  background: var(--color-gold-faint);
  border: 1px solid var(--color-gold-light);
  padding: 2px 8px;
  border-radius: 99px;
  text-align: center;
  text-transform: capitalize;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* ---- Page Content ---- */
.page-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1400px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-text);
}

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

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

.breadcrumb a { color: var(--color-primary); }
.breadcrumb-sep { color: var(--color-border-strong); }

/* ---- Notification Bell ---- */
.notif-bell {
  position: relative;
  background: none;
  border: none;
  padding: 6px;
  border-radius: 8px;
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.notif-bell:hover { background: var(--color-surface-2); color: var(--color-primary); }
.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  min-width: 16px;
  height: 16px;
  background: var(--color-danger);
  color: #fff;
  border-radius: 99px;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  display: none;
}
.notif-badge.visible { display: flex; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar-logo-text,
  .sidebar-nav a span,
  .sidebar-section-label,
  .sidebar-footer { display: none; }
  .sidebar-nav a { justify-content: center; padding: 12px; }
  .main-content { margin-left: var(--sidebar-collapsed); }
}

@media (max-width: 768px) {
  .page-content { padding: 16px; }
}

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 60%, #A0503C 100%);
}

.login-card {
  background: var(--color-surface);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.login-logo img {
  height: 72px;
  object-fit: contain;
  margin-bottom: 8px;
}

.login-logo .login-tagline {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 24px;
}

/* ---- Toast notifications ---- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--color-surface);
  border-radius: var(--border-radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--color-primary);
  font-size: 0.875rem;
  max-width: 340px;
  pointer-events: all;
  animation: slideIn 0.2s ease;
}

.toast.success { border-left-color: var(--color-success); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ---- Loading spinner ---- */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  gap: 12px;
  color: var(--color-text-muted);
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-text-muted);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  opacity: 0.3;
  margin-bottom: 16px;
}

.empty-state p { font-size: 0.95rem; }
