/* ===========================
   KAIROS - DESIGN SYSTEM
   =========================== */

:root {
  /* Color Palette */
  --primary: #6C63FF;
  --danger: #FF4757;
  --warning: #FFA502;
  --success: #2ED573;
  
  --dark-bg: #0F0F1A;
  --dark-card: #1A1A2E;
  --dark-surface: #16213E;
  
  --light-bg: #F4F6FF;
  --light-card: #FFFFFF;
  --light-surface: #F0F3FF;
  
  /* Typography - will load from Google Fonts */
  --font-primary: 'Poppins', 'Inter', sans-serif;
  
  /* Spacing (8px grid) */
  --spacing-xs: 0.25rem;  /* 4px */
  --spacing-sm: 0.5rem;   /* 8px */
  --spacing-md: 1rem;     /* 16px */
  --spacing-lg: 1.5rem;   /* 24px */
  --spacing-xl: 2rem;     /* 32px */
  --spacing-2xl: 3rem;    /* 48px */
  
  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  
  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-smooth: 0.3s ease;
  --transition-slow: 0.5s ease;
  
  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-bg: 400;
  --z-modal: 500;
  --z-toast: 600;
}

body.dark-mode {
  --bg: var(--dark-bg);
  --card-bg: var(--dark-card);
  --surface: var(--dark-surface);
  --text: #E0E0E0;
  --text-secondary: #A0A0A0;
  --border: #2A2A3E;
}

body.light-mode {
  --bg: #ECEEF8;
  --card-bg: #F8F9FF;
  --surface: #EDEFFE;
  --text: #1A1A2E;
  --text-secondary: #6B7280;
  --border: #DFE1F0;
}

/* ===========================
   RESET & BASE STYLES
   =========================== */

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

@media (max-width: 1400px) {
  html {
    font-size: 14px;
  }
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background-color var(--transition-smooth),
              color var(--transition-smooth);
  overflow-x: hidden;
  zoom: 1;
}

@supports not (zoom: 1) {
  body {
    transform: scale(1);
    transform-origin: top left;
    width: 100%;
    min-height: 100vh;
  }
}

body.light-mode {
  background-image:
    radial-gradient(ellipse 70% 55% at 0% 0%,   rgba(108, 99, 255, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 55% 45% at 100% 100%, rgba(168, 85, 247, 0.06) 0%, transparent 55%),
    radial-gradient(ellipse 40% 35% at 60% 0%,   rgba(46, 213, 115, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
}

body.dark-mode {
  background-image:
    radial-gradient(ellipse 60% 50% at 0% 0%,   rgba(108, 99, 255, 0.12) 0%, transparent 55%),
    radial-gradient(ellipse 50% 45% at 100% 100%, rgba(168, 85, 247, 0.08) 0%, transparent 55%);
  background-attachment: fixed;
}

/* Typography */
h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: var(--spacing-md);
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: var(--spacing-md);
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
}

p {
  margin-bottom: var(--spacing-md);
  color: var(--text-secondary);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary);
  opacity: 0.8;
}

/* ===========================
   BUTTONS
   =========================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-smooth);
  font-family: var(--font-primary);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Button Variants */
.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  opacity: 0.9;
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.9;
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface);
}

.btn-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  background: transparent;
  color: var(--text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--surface);
}

.user-profile-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.user-profile-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  background: transparent;
  border: 1px solid var(--border);
  padding: var(--spacing-xs) var(--spacing-md);
  border-radius: var(--radius-lg);
  cursor: pointer;
  color: var(--text);
  font-family: var(--font-primary);
  transition: all var(--transition-fast);
}

.user-profile-btn:hover {
  background: var(--surface);
  border-color: var(--primary);
}

.user-profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.user-profile-name {
  font-weight: 500;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-profile-dropdown {
  position: absolute;
  top: calc(100% + var(--spacing-sm));
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-width: 250px;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  overflow: hidden;
  transform: scaleY(0);
  transform-origin: top;
  transition: transform var(--transition-fast);
}

.user-profile-dropdown.active {
  transform: scaleY(1);
}

.user-profile-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.user-profile-title {
  font-weight: 600;
  color: var(--text);
}

.user-profile-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.user-profile-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--text);
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: var(--font-primary);
  transition: all var(--transition-fast);
}

.user-profile-item:hover {
  background: var(--surface);
  color: var(--primary);
  padding-left: calc(var(--spacing-md) + var(--spacing-sm));
}

.user-profile-item.danger:hover {
  background: rgba(255, 71, 87, 0.1);
  color: var(--danger);
}

.user-profile-divider {
  height: 1px;
  background: var(--border);
  margin: var(--spacing-xs) 0;
}

.btn-sm {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: 0.875rem;
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-xl);
  font-size: 1.125rem;
}

/* ===========================
   INPUTS & FORMS
   =========================== */

input, textarea, select {
  font-family: var(--font-primary);
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-size: 1rem;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}

input::placeholder {
  color: var(--text-secondary);
}

input.error, textarea.error {
  border-color: var(--danger);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: var(--text);
}

.form-group .error-message {
  color: var(--danger);
  font-size: 0.875rem;
  margin-top: var(--spacing-xs);
}

/* ===========================
   UTILITIES
   =========================== */

.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.flex {
  display: flex;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.grid {
  display: grid;
}

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.text-center { text-align: center; }
.text-right { text-align: right; }

.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }

.font-bold { font-weight: 700; }
.font-semi { font-weight: 600; }
.font-light { font-weight: 400; }

.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

.cursor-pointer { cursor: pointer; }

.hidden { display: none !important; }
.visible { display: block !important; }

.mt- { margin-top: var(--spacing-md); }
.mb { margin-bottom: var(--spacing-md); }
.p { padding: var(--spacing-md); }

/* Responsive utilities */
.mobile-only {
  display: block;
}

.tablet-only {
  display: none;
}

.desktop-only {
  display: none;
}

@media (min-width: 768px) {
  .mobile-only { display: none; }
  .tablet-only { display: block; }
}

@media (min-width: 1024px) {
  .tablet-only { display: none; }
  .desktop-only { display: block; }
}

/* ===========================
   SCROLLBAR
   =========================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ===========================
   ANIMATIONS
   =========================== */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  0%   { opacity: 0; transform: scale(0.88); }
  70%  { transform: scale(1.03); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes fabPulse {
  0%   { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0.45); }
  70%  { box-shadow: 0 0 0 12px rgba(108, 99, 255, 0); }
  100% { box-shadow: 0 0 0 0 rgba(108, 99, 255, 0); }
}

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

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

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* ===========================
   NAVBAR & SIDEBAR
   =========================== */

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: var(--spacing-md) var(--spacing-lg);
  height: 70px;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

body.light-mode .navbar {
  background-color: rgba(255, 255, 255, 0.82);
}

body.dark-mode .navbar {
  background-color: rgba(26, 26, 46, 0.82);
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  flex: 1;
}

.navbar-toggle {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  padding: var(--spacing-sm);
  border-radius: var(--radius-md);
  transition: background-color var(--transition-fast);
}

.navbar-toggle:hover {
  background-color: var(--surface);
}

.navbar-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.sidebar {
  width: 250px;
  background-color: var(--card-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: var(--z-fixed);
  overflow-y: auto;
  transition: transform var(--transition-smooth);
}

.sidebar-header {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.sidebar-header:hover {
  background-color: var(--surface);
}

.sidebar-logo-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: transparent;
}

.sidebar-logo-icon img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 0 8px rgba(108,99,255,0.3));
}

.sidebar-nav {
  flex: 1;
  padding: var(--spacing-md) 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-lg);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  font-family: var(--font-primary);
}

.nav-item:hover {
  color: var(--text);
  background-color: var(--surface);
  padding-left: calc(var(--spacing-lg) + var(--spacing-sm));
}

.nav-item.active {
  color: var(--primary);
  background-color: rgba(108, 99, 255, 0.1);
  border-left: 3px solid var(--primary);
  padding-left: calc(var(--spacing-lg) - 3px);
}

.nav-item i {
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: var(--spacing-md) 0;
}

/* Mobile sidebar toggle */
@media (max-width: 767px) {
  .navbar-toggle {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 100%;
    max-width: 300px;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  body.sidebar-open {
    overflow: hidden;
  }
}

/* ===========================
   RESPONSIVE
   =========================== */

@media (max-width: 360px) {
  html {
    font-size: 14px;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }
}

@media (max-width: 767px) {
  .container {
    padding: 0 var(--spacing-sm);
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: var(--spacing-sm);
  }

  h2 {
    font-size: 1.25rem;
    margin-bottom: var(--spacing-sm);
  }

  h3 {
    font-size: 1rem;
    margin-bottom: var(--spacing-xs);
  }

  p {
    margin-bottom: var(--spacing-sm);
    font-size: 0.95rem;
  }

  .btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.95rem;
    min-height: 44px;
    min-width: 44px;
  }

  .btn-icon {
    width: 2.2rem;
    height: 2.2rem;
  }

  input, textarea, select {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 16px;
    min-height: 44px;
  }

  .form-group {
    margin-bottom: var(--spacing-md);
  }
}
