/* ========================================
   ERP System - Основные стили
   Тёмный glassmorphism с неоновым акцентом
======================================== */

/* CSS Variables */
:root {
  /* Цвета фона */
  --bg-primary: #0b0f16;
  --bg-secondary: #0e1320;
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.06);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-input: rgba(255, 255, 255, 0.08);
  --accent: #00bbff;
  --accent-hover: #51f2ff;
  --accent-glow: rgba(182, 255, 46, 0.3);
  --accent-soft: rgb(46 196 255 / 15%);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-muted: rgba(255, 255, 255, 0.4);
  --text-dark: #0b0f16;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --border-color: rgba(255, 255, 255, 0.1);
  --border-focus: rgba(182, 255, 46, 0.5);
  --sidebar-width: 280px;
  --topbar-height: 70px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}


body {
    min-height: 100vh;
    background: var(--bg-primary);
    position: relative;
}


body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    background-image: 
        repeating-linear-gradient(0deg, transparent 0px, transparent 40px, rgba(143, 217, 0, 0.025) 40px, rgba(143, 217, 0, 0.025) 41px),
        repeating-linear-gradient(90deg, transparent 0px, transparent 40px, rgba(0, 187, 255, 0.02) 40px, rgba(0, 187, 255, 0.02) 41px);
    animation: wave-lines 50s ease-in-out infinite;
    z-index: -1;
    pointer-events: none;
    filter: blur(1px);
}

@keyframes wave-lines {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
    }
    25% {
        transform: translate(-5%, 5%) rotate(1deg);
    }
    50% {
        transform: translate(-10%, 0) rotate(0deg);
    }
    75% {
        transform: translate(-5%, -5%) rotate(-1deg);
    }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

select {
    color-scheme: dark; /* Ключевая строка для темной темы в Windows */
}

/* Попытка стилизовать сами опции (работает частично в разных браузерах) */
select option {
    background-color: #1e1e1e;
    color: white;
}

/* ========================================
   Layout
======================================== */

.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent) 0%, #8fd900 100%);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
}

.logo-icon i {
  color: var(--text-dark);
  width: 24px;
  height: 24px;
}

.logo-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.logo-text span {
  color: var(--accent);
}

/* Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  margin-bottom: 4px;
}

.nav-link i {
  width: 20px;
  height: 20px;
  opacity: 0.7;
  transition: all var(--transition-fast);
}

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

.nav-link:hover i {
  opacity: 1;
}

.nav-link.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.nav-link.active i {
  opacity: 1;
  color: var(--accent);
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--text-dark);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-card:hover {
  background: var(--bg-card-hover);
}

.logs-filters-card {
    margin-top: 20px;
}

.log-date {
    font-size: 0.8rem!important;
    color: var(--text-muted)!important;
    margin-top: 2px!important;
}

.log-time {
    font-size: 1rem!important;
    font-weight: 600!important;
    color: var(--text-primary)!important;
}

.user-avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--accent) 0%, #8fd900 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-dark);
  font-size: 0.9rem;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--accent);
}

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

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.menu-toggle:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}

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

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-right .search-box svg {
  position: absolute;
  left: 10px;
  top: 6px;
}

.logo-icon svg {
  stroke: #fff;
}

/* Search */
.search-box {
  position: relative;
  width: 280px;
}

.search-box input {
  width: 100%;
  padding: 10px 16px 10px 44px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--text-primary);
  font-size: 0.9rem;
  outline: none;
  transition: all var(--transition-fast);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.search-box input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

/* Topbar Icons */
.topbar-icon {
  position: relative;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.topbar-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.topbar-icon i {
  width: 20px;
  height: 20px;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
}

/* Page Content */
.page-content {
  flex: 1;
  padding: 32px;
}

/* ========================================
   Typography
======================================== */

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
  color: var(--text-secondary);
}

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

a:hover {
  color: var(--accent-hover);
}

/* ========================================
   Animations
======================================== */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

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

.animate-fade-in {
  animation: fadeIn var(--transition-normal) ease;
}

.animate-slide-up {
  animation: slideUp var(--transition-normal) ease;
}

.animate-scale-in {
  animation: scaleIn var(--transition-normal) ease;
}

/* ========================================
   Responsive
======================================== */

@media (max-width: 1200px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .menu-toggle {
    display: flex;
  }
  
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
  }
  
  .sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding: 0 16px;
  }
  
  .search-box {
    display: none;
  }
  
  .page-content {
    padding: 16px;
  }
  
  .page-title {
    font-size: 1.25rem;
  }
}



/* ========================================
   Sidebar Collapsed State
======================================== */

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  margin-left: auto;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.sidebar-toggle-icon {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-normal);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Collapsed State */
.sidebar.sidebar-collapsed {
  width: 80px;
}

.sidebar.sidebar-collapsed .logo-text {
  display: none;
}

.sidebar.sidebar-collapsed .nav-section-title {
  display: none;
}

.sidebar.sidebar-collapsed .nav-link span {
  display: none;
}

.sidebar.sidebar-collapsed .nav-badge {
  display: none;
}

.sidebar.sidebar-collapsed .nav-link {
  justify-content: center;
  padding: 12px;
}

.sidebar.sidebar-collapsed .nav-link i {
  margin: 0;
}

.sidebar.sidebar-collapsed .user-info {
  display: none;
}

.sidebar.sidebar-collapsed .user-card {
  justify-content: center;
  padding: 0;
    gap: 0;
}

.sidebar.sidebar-collapsed .user-card-wrapper svg {
    display: none;
}

.sidebar.sidebar-collapsed .user-card i[data-lucide="chevron-down"] {
  display: none;
}

.sidebar.sidebar-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.sidebar.sidebar-collapsed .sidebar-toggle-btn {
  margin: 0 auto;
}

.sidebar.sidebar-collapsed .sidebar-header {
  flex-direction: column;
  gap: 12px;
}

.sidebar.sidebar-collapsed .logo {
  justify-content: center;
}

.sidebar.sidebar-collapsed + .main-content {
  margin-left: 80px;
}

/* User menu dropdown adjustments for collapsed sidebar */
.sidebar.sidebar-collapsed .user-card-wrapper {
  position: relative;
}

.sidebar.sidebar-collapsed .user-menu-dropdown {
    left: 100%;
    bottom: 0;
    margin-left: 8px;
    width: 200px;
}

/* Animation */
.sidebar, .sidebar-toggle-icon, .main-content {
  transition: all var(--transition-normal);
}

/* ========================================
   History Table Styles
======================================== */

.currency-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.currency-toggle button {
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.currency-toggle button.active {
  background: var(--accent);
  color: var(--text-dark);
}

.currency-toggle button:hover:not(.active) {
  color: var(--text-primary);
}

/* Grouping toggle */
/* Modern Grouping Toggle Styles */
.grouping-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.grouping-toggle label:first-child {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.grouping-toggle .toggle-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.grouping-toggle .toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.grouping-toggle .toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.grouping-toggle .toggle-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 2px;
  background: linear-gradient(135deg, #ffffff, #e0e0e0);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

.grouping-toggle .toggle-switch:hover .toggle-slider {
  border-color: rgba(255, 255, 255, 0.2);
}

.grouping-toggle .toggle-switch:hover .toggle-slider:before {
  box-shadow: 
    0 3px 10px rgba(0, 0, 0, 0.4),
    0 2px 4px rgba(0, 0, 0, 0.2);
}

.grouping-toggle input:checked + .toggle-slider {
  background: linear-gradient(135deg, #00d4ff, #00a8cc);
  border-color: rgba(0, 191, 255, 0.3);
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.1),
    0 0 16px rgba(0, 191, 255, 0.3);
}

.grouping-toggle input:checked + .toggle-slider:before {
  transform: translateX(24px);
  background: linear-gradient(135deg, #ffffff, #f0f8ff);
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.2),
    0 0 8px rgba(0, 191, 255, 0.4);
}

.grouping-toggle input:focus + .toggle-slider {
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.2),
    0 0 0 3px rgba(0, 191, 255, 0.2);
}

/* Action buttons */
.action-btn {
  background: transparent;
  border: none;
  padding: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
}

.action-btn.view:hover {
  color: var(--info);
}

.action-btn.edit:hover {
  color: var(--accent);
}

.action-btn.delete:hover {
  color: var(--danger);
}

.action-btn svg {
  width: 16px;
  height: 16px;
}

/* Batch group styles */
.batch-group-header {
  background: rgba(0, 187, 255, 0.08) !important;
  cursor: pointer;
  user-select: none;
}

.batch-group-header:hover {
  background: rgba(0, 187, 255, 0.12) !important;
}

.batch-group-header td {
  padding: 12px 16px !important;
  font-weight: 600;
}

.batch-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.batch-toggle-icon {
  transition: transform var(--transition-fast);
}

.batch-toggle-icon.expanded {
  transform: rotate(90deg);
}

.batch-item-row {
  background: rgba(255, 255, 255, 0.02);
}

.batch-item-row.hidden {
  display: none;
}

.batch-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
}


/* ========================================
   Multi-Currency Revenue Display
======================================== */
.kpi-value-multi {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-value-line {
  font-size: clamp(0.9rem, 2vw, 1.3rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  word-break: break-word;
  overflow-wrap: break-word;
}

.kpi-value-usd {
  color: #10b981; /* Green for USD */
}

.kpi-value-uzs {
  color: #3b82f6; /* Blue for UZS */
  font-size: clamp(0.8rem, 1.5vw, 1rem);
}

/* ========================================
   Autocomplete Dropdown Fix
======================================== */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
}

.autocomplete-dropdown.active {
  display: block;
}

.autocomplete-item {
  padding: 10px 12px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.autocomplete-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.autocomplete-wrapper {
  position: relative;
}



/* ========================================
   Client Avatar Styles
   ======================================== */

.client-avatar-sm {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

.client-avatar {
  width: 60px;
  height: 60px;
  min-width: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 24px;
}

.client-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.client-name {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.client-phone {
  color: var(--text-secondary);
}

.client-email {
  font-size: 13px;
}

.client-stats {
  display: flex;
  gap: 24px;
  padding: 16px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.client-stat {
  text-align: center;
}

.client-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-primary);
}

.client-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}