/* ===================================================================
   app.css — Shared Admin Styles & Theming
   CSS custom properties, animations, and common component classes
   shared across all admin pages.
   =================================================================== */

/* ===================================================================
   1. THEME CSS VARIABLES
   =================================================================== */
:root {
  /* Backgrounds */
  --bg-primary: #161617;
  --bg-card: #1c1c1e;
  --bg-surface: rgba(28, 28, 30, 0.6);
  --bg-elevated: rgba(28, 28, 30, 0.95);

  /* Borders */
  --border-color: #333336;
  --border-light: rgba(255, 255, 255, 0.05);

  /* Text */
  --text-primary: #f5f5f7;
  --text-secondary: #86868b;
  --text-muted: #636366;

  /* Hover states */
  --hover-bg: rgba(255, 255, 255, 0.06);
  --hover-bg-strong: rgba(255, 255, 255, 0.1);

  /* Brand / accent */
  --accent-red: #e30a17;
  --accent-red-hover: #c50610;
  --accent-amber: #f45b69;

  /* Shadows */
  --shadow-card: 0 20px 60px rgba(0, 0, 0, 0.5);

  /* Semantic colors */
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #f43f5e;

  /* Fonts */
  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-card: #f5f5f7;
  --bg-surface: rgba(255, 255, 255, 0.8);
  --bg-elevated: rgba(255, 255, 255, 0.95);

  --border-color: #e4e4e7;
  --border-light: rgba(0, 0, 0, 0.05);

  --text-primary: #18181b;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;

  --hover-bg: rgba(0, 0, 0, 0.04);
  --hover-bg-strong: rgba(0, 0, 0, 0.08);

  --accent-red: #dc2626;
  --accent-red-hover: #b91c1c;
  --accent-amber: #f97316;

  --shadow-card: 0 20px 60px rgba(0, 0, 0, 0.1);

  --success: #16a34a;
  --warning: #d97706;
  --danger: #e11d48;
}

/* ===================================================================
   2. THEME-AWARE UTILITY CLASSES
   Replace hardcoded Tailwind arbitrary values so they respond
   to [data-theme] changes.  Usage in HTML:
     class="text-primary"  instead of  class="text-[#f4f4f5]"
     class="bg-card"       instead of  class="bg-[#1c1c1e]"
   =================================================================== */

/* ── Text colours ── */
.text-primary   { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted     { color: var(--text-muted) !important; }

/* ── Background colours ── */
.bg-primary     { background-color: var(--bg-primary) !important; }
.bg-card        { background-color: var(--bg-card) !important; }
.bg-surface     { background-color: var(--bg-surface) !important; }

/* ── Border colours ── */
.border-default { border-color: var(--border-color) !important; }

/* ── Semantic colour tokens (theme-aware) ── */
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger) !important; }
.text-brand   { color: var(--accent-amber) !important; }

.bg-success-soft { background-color: color-mix(in srgb, var(--success) 10%, transparent) !important; }
.bg-warning-soft { background-color: color-mix(in srgb, var(--warning) 10%, transparent) !important; }
.bg-danger-soft  { background-color: color-mix(in srgb, var(--danger) 10%, transparent) !important; }
.bg-brand-soft   { background-color: color-mix(in srgb, var(--accent-red) 10%, transparent) !important; }

/* Brand logo gradient (theme-aware) */
.brand-logo-bg {
  background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-amber) 100%) !important;
}

/* Additional brand accent tokens (theme-aware) */
.text-brand-red   { color: var(--accent-red) !important; }
.text-brand-amber { color: var(--accent-amber) !important; }

.bg-brand-red        { background-color: var(--accent-red) !important; }
.bg-brand-amber      { background-color: var(--accent-amber) !important; }
.bg-brand-red-soft   { background-color: color-mix(in srgb, var(--accent-red) 10%, transparent) !important; }
.bg-brand-red-medium { background-color: color-mix(in srgb, var(--accent-red) 20%, transparent) !important; }

.border-brand-red-soft { border-color: color-mix(in srgb, var(--accent-red) 20%, transparent) !important; }

/* ===================================================================
   3. THEME TOGGLE BUTTON
   =================================================================== */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}
.theme-toggle:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
  border-color: var(--accent-red);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
}

/* ===================================================================
   3. COMMON ANIMATIONS
   Extracted from input.css — shared keyframes and animation classes
   =================================================================== */

/* ── Fade in ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Slide up ── */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Fade + slide (used by glass-panel) ── */
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Pulse dot ── */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* ── Animation utility classes ── */
.animate-fade-in {
  animation: fadeIn 0.4s ease forwards;
}
.animate-slide-up {
  animation: slideUp 0.5s ease forwards;
}

/* ===================================================================
   4. SHARED COMPONENT STYLES
   Common elements used across admin pages.
   =================================================================== */

/* ── Status dot ── */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}
.status-dot.pulse {
  animation: pulse-dot 2s infinite;
}

/* ── Brand gradient text ── */
.brand-gradient {
  background: linear-gradient(135deg, var(--accent-red) 0%, var(--accent-amber) 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}

/* ── Custom scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===================================================================
   5. THEME TRANSITION
   Smooth transitions for theme switching via CSS custom properties.
   =================================================================== */
*,
*::before,
*::after {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

/* ===================================================================
   6. COLLAPSIBLE SIDEBAR (мини-сайдбар 64px)
   =================================================================== */

/* ── Toggle button ── */
/* Align toggle button relative to the aside sidebar itself to place it at 50% height */

.sidebar-toggle-btn {
  position: absolute;
  right: -12px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50% !important;
  border: 1px solid var(--border-color);
  background: var(--bg-card) !important;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover {
  background: var(--hover-bg);
  color: var(--text-primary);
  border-color: var(--accent-red);
}
.sidebar-toggle-btn svg {
  width: 14px;
  height: 14px;
  transition: transform 0.3s ease;
  transform: rotate(180deg);
}

/* ── Collapsed state (только для desktop >= 1024px) ── */
@media (min-width: 1024px) {
  body.sidebar-collapsed .sidebar-desktop,
  body.sidebar-collapsed .glass-sidebar,
  body.sidebar-collapsed aside,
  body.sidebar-collapsed .sidebar-glass {
    width: 64px !important;
    overflow: visible !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  /* Скрываем текст и лишние элементы */
  body.sidebar-collapsed aside .sidebar-text-group,
  body.sidebar-collapsed .sidebar-desktop .sidebar-text-group,
  body.sidebar-collapsed .sidebar-desktop .brand-gradient,
  body.sidebar-collapsed .sidebar-desktop .sidebar-badge,
  body.sidebar-collapsed .sidebar-desktop .nav-label,
  body.sidebar-collapsed .glass-sidebar .brand-gradient,
  body.sidebar-collapsed .glass-sidebar .acmo-badge,
  body.sidebar-collapsed .glass-sidebar .nav-label,
  body.sidebar-collapsed aside .brand-text,
  body.sidebar-collapsed aside .brand-badge,
  body.sidebar-collapsed aside .nav-label,
  body.sidebar-collapsed .sidebar-glass .gradient-brand,
  body.sidebar-collapsed .sidebar-glass .text-brand-amber,
  body.sidebar-collapsed .sidebar-glass .sidebar-footer-text,
  body.sidebar-collapsed .sidebar-glass .nav-label {
    display: none !important;
  }

  /* Поворачиваем иконку toggle */
  body.sidebar-collapsed .sidebar-toggle-btn svg {
    transform: rotate(0deg);
  }

  /* Расширяем контент */
  body.sidebar-collapsed main,
  body.sidebar-collapsed .main-offset {
    margin-left: 64px !important;
  }

  /* Центрируем иконки навигации */
  body.sidebar-collapsed .sidebar-desktop .nav-item,
  body.sidebar-collapsed .glass-sidebar .nav-item,
  body.sidebar-collapsed aside .nav-item,
  body.sidebar-collapsed .sidebar-glass .nav-item {
    justify-content: center;
    padding: 0.7rem 0.5rem;
  }

  body.sidebar-collapsed .sidebar-desktop .nav-icon,
  body.sidebar-collapsed .glass-sidebar .nav-icon,
  body.sidebar-collapsed aside .nav-icon,
  body.sidebar-collapsed .sidebar-glass .nav-icon {
    font-size: 1.1rem;
    margin: 0;
  }

  /* Бренд в свернутом режиме — только буква */
  body.sidebar-collapsed aside .px-5,
  body.sidebar-collapsed aside .brand,
  body.sidebar-collapsed .sidebar-desktop .px-5,
  body.sidebar-collapsed .glass-sidebar .brand a,
  body.sidebar-collapsed .sidebar-glass .px-5 {
    justify-content: center !important;
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
  }

  /* Скрываем разделители бренда */
  body.sidebar-collapsed .brand-divider {
    display: none;
  }

  /* Логаут — только иконка */
  body.sidebar-collapsed .nav-logout .nav-label,
  body.sidebar-collapsed .logout-item .nav-label {
    display: none !important;
  }

}

