/* CSS Variables for Premium Light SaaS Design System */
:root {
  /* Color System */
  --app-bg: #F5F3FF;              /* Soft lavender canvas (body background) */
  --page-bg: #FAFAFF;             /* Main workspace inner background */
  --surface: #FFFFFF;             /* Crisp pure white for cards, tables, inputs */
  --surface-soft: #F8F7FF;        /* Gentle hover states & side regions */
  --surface-muted: #F1F0FA;       /* Muted elements & table headers */

  /* Borders & Dividers */
  --border-light: rgba(32, 24, 64, 0.08);   /* Low-contrast divider */
  --border-medium: rgba(32, 24, 64, 0.12);  /* Focus states & interactive borders */

  /* Typography */
  --text-primary: #171326;        /* Deep charcoal purple for high readability */
  --text-secondary: #6F6A80;      /* Muted text for descriptions & labels */
  --text-muted: #9B96AA;          /* Light disabled / placeholder text */

  /* Brand Accents */
  --primary: #7C6DF2;
  --primary-hover: #6B5DE6;
  --primary-soft: rgba(124, 109, 242, 0.12); /* Active states & highlights */

  /* Semantic Highlights */
  --success: #16C79A;
  --success-soft: rgba(22, 199, 154, 0.12);
  --warning: #F5B84B;
  --warning-soft: rgba(245, 184, 75, 0.16);
  --danger: #EF6A7A;
  --danger-soft: rgba(239, 106, 122, 0.12);
  --info: #38BDF8;
  --info-soft: rgba(56, 189, 248, 0.12);

  /* Typography Settings */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  /* Border Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  /* Transitions & Subtle Shadows */
  --transition-fast: 0.15s ease-in-out;
  --transition-normal: 0.25s ease-in-out;
  --shadow-subtle: 0 1px 3px 0 rgba(32, 24, 64, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(32, 24, 64, 0.06), 0 2px 6px -2px rgba(32, 24, 64, 0.04);
  --shadow-modal: 0 20px 25px -5px rgba(32, 24, 64, 0.1), 0 10px 10px -5px rgba(32, 24, 64, 0.04);

  /* Backward Compatibility Mappings */
  --bg-primary: var(--page-bg);
  --bg-secondary: var(--surface);
  --bg-base: var(--page-bg);
  --bg-surface: var(--surface);
  --bg-surface-hover: var(--surface-soft);
  --surface-hover: var(--surface-soft);
  --text-main: var(--text-primary);
  --text-muted: var(--text-secondary);
  --border-color: var(--border-light);
  --border-focus: var(--primary);
  --primary-hover-legacy: #818cf8;
  --primary-glow: rgba(124, 109, 242, 0.05);

  --layer-base: var(--page-bg);
  --layer-sidebar: var(--surface);
  --layer-card: var(--surface);
  --layer-input: var(--surface);
  --layer-modal: var(--surface);
  --layer-dropdown: var(--surface);

  --success-bg: var(--success-soft);
  --success-text: var(--success);
  --warning-bg: var(--warning-soft);
  --warning-text: var(--warning);
  --danger-bg: var(--danger-soft);
  --danger-text: var(--danger);
  --info-bg: var(--info-soft);
  --info-text: var(--info);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--app-bg);
  color: var(--text-primary);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Layout Shell with Rounded Workspace Layer */
.app-layout {
  display: flex;
  height: calc(100vh - 32px);
  width: calc(100vw - 32px);
  background-color: var(--page-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background-color: var(--layer-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-header {
  height: 72px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  gap: 12px;
}

.sidebar-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
  margin: 0;
}

.logo-mark {
  display: block;
  width: auto;
  height: 34px;
  max-width: 140px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-nav {
  padding: 24px 12px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 20px;
}

.nav-section-title {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  opacity: 0.65;
  padding: 0 12px 6px 12px;
  user-select: none;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 6px;
  font-weight: 500;
  font-size: 0.88rem;
  transition: background-color var(--transition-fast), color var(--transition-fast), padding-left var(--transition-fast);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-icon {
  margin-right: 10px;
  flex-shrink: 0;
  opacity: 0.7;
  color: var(--text-secondary);
  transition: transform var(--transition-fast), opacity var(--transition-fast), color var(--transition-fast);
}

.nav-link:hover {
  background-color: var(--surface-soft);
  color: var(--text-primary);
}

.nav-link:hover .nav-icon {
  opacity: 0.95;
  color: var(--text-primary);
  transform: scale(1.02);
}

.nav-link.active {
  background-color: var(--primary-soft);
  color: var(--primary);
  font-weight: 500;
}

.nav-link.active .nav-icon {
  opacity: 1;
  color: var(--primary);
}

/* Main Content Area */
.main-wrapper {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--page-bg);
  position: relative;
}

/* Header */
.app-header {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  z-index: 5;
}

#page-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-transform: capitalize;
  color: var(--text-primary);
}

.header-actions {
  display: flex;
  align-items: center;
}

.global-page-selector {
  background-color: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.88rem;
  margin-right: 16px;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
  max-width: 250px;
}

.global-page-selector:focus {
  outline: none;
  border-color: #6366f1;
}

/* User Menu & Logout */
.header-user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px;
  padding-left: 16px;
  border-left: 1px solid #1E293B;
}

.logout-btn {
  background: transparent;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: #1E293B;
  color: #F87171;
}

.global-page-status {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-right: 16px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--surface-soft);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.user-avatar:hover {
  border-color: var(--border-focus);
}

/* Main Content Wrapper */
.main-content {
  flex-grow: 1;
  padding: 32px;
  overflow-y: auto;
  position: relative;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--layer-base); 
}
::-webkit-scrollbar-thumb {
  background: var(--surface); 
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--surface-hover); 
}

/* ==========================================
   Core Component System Styles (Base Layouts)
   ========================================== */

/* Cards Base */
.card-base {
  background-color: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-subtle);
}

/* Inputs & Form Fields */
.input-base {
  background-color: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9rem;
  padding: 10px 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
  box-shadow: var(--shadow-subtle);
}
.input-base:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-soft);
}
.input-base::placeholder {
  color: var(--text-muted);
}

select.input-base {
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M7 9l3 3 3-3' stroke='%236F6A80' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 18px;
  padding-right: 36px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

/* Buttons System */
.btn-primary-base {
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary-base:hover {
  background-color: var(--primary-hover);
}
.btn-primary-base:disabled {
  background-color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.btn-secondary-base {
  background-color: var(--surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-secondary-base:hover {
  background-color: var(--surface-soft);
  color: var(--text-primary);
  border-color: var(--border-medium);
}
.btn-secondary-base:disabled {
  background-color: var(--surface-soft);
  color: var(--text-muted);
  border-color: var(--border-color);
  cursor: not-allowed;
}

.btn-ghost-base {
  background-color: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-ghost-base:hover {
  background-color: var(--primary-soft);
  color: var(--primary);
}

.btn-danger-base {
  background-color: var(--danger);
  color: #ffffff;
  border: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: opacity var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-danger-base:hover {
  opacity: 0.9;
}

/* Muted semantic tags and badges */
.badge-success-base {
  background-color: var(--success-bg);
  color: var(--success-text);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.badge-warning-base {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.badge-danger-base {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}
.badge-info-base {
  background-color: var(--info-bg);
  color: var(--info-text);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
}

/* Table System Style */
.table-base {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.table-base th {
  background-color: var(--surface-muted);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}
.table-base td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 0.88rem;
}
.table-base tr {
  background-color: var(--surface);
  transition: background-color var(--transition-fast);
}
.table-base tr:hover {
  background-color: var(--surface-soft);
}

/* Modal Dialog Overlay and Wrapper System */
.modal-overlay-base {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(23, 19, 38, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
}
.modal-wrapper-base {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  z-index: 101;
  width: 90%;
  max-width: 500px;
  overflow: hidden;
}
