/* ========================================
   V2RAY IRAN - MODERN BLUE PURPLE THEME
   ======================================== */

:root {
  --primary: #5B77EE;
  --primary-dark: #4A63D4;
  --primary-light: #8EABFB;
  --purple: #7C6BF0;
  --purple-light: #A78BFA;
  --bg-soft: #EDE4FF;
  --bg-card: #FFFFFF;
  --bg-input: #F5F0FF;
  --border-color: #D8CCF0;
  --text-primary: #1A1A2E;
  --text-secondary: #4A4A6A;
  --text-light: #8A8AAA;
  --text-white: #FFFFFF;
  --shadow-sm: 0 2px 12px rgba(91, 119, 238, 0.08);
  --shadow-md: 0 4px 24px rgba(91, 119, 238, 0.12);
  --shadow-lg: 0 8px 48px rgba(91, 119, 238, 0.15);
  --shadow-xl: 0 12px 64px rgba(91, 119, 238, 0.20);
  --gradient-primary: linear-gradient(135deg, #5B77EE 0%, #7C6BF0 50%, #8EABFB 100%);
  --gradient-secondary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background: var(--bg-soft);
  color: var(--text-primary);
  min-height: 100vh;
  direction: rtl;
  background-image: 
    radial-gradient(ellipse at 10% 20%, rgba(124, 107, 240, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 90% 80%, rgba(91, 119, 238, 0.08) 0%, transparent 60%);
  transition: background 0.3s ease, color 0.3s ease;
}

html { scroll-behavior: smooth; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-soft); border-radius: 3px; }
::-webkit-scrollbar-thumb { background: var(--gradient-primary); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gradient-secondary); }

/* ========================================
   DARK MODE TOGGLE SWITCH
   ======================================== */
.theme-toggle-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.15);
  padding: 6px 16px 6px 16px;
  border-radius: 30px;
  border: 1px solid rgba(255,255,255,0.1);
}

.theme-toggle-wrapper .theme-icon {
  font-size: 22px;
  line-height: 1;
  transition: all 0.3s ease;
}

.switch {
  position: relative;
  width: 50px;
  height: 28px;
  background: rgba(255,255,255,0.25);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid rgba(255,255,255,0.3);
  flex-shrink: 0;
}

.switch:hover { transform: scale(1.05); }

.switch.active {
  background: rgba(91, 119, 238, 0.5);
  border-color: var(--primary);
  box-shadow: 0 0 20px rgba(91, 119, 238, 0.3);
}

.switch .slider {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50%;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}

.switch.active .slider {
  transform: translateX(22px);
  background: white;
  box-shadow: 0 2px 16px rgba(91, 119, 238, 0.4);
}

/* ========================================
   GLASS CARD
   ======================================== */
.glass-card {
  background: var(--bg-card);
  border: 1px solid rgba(91, 119, 238, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.glass-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
  border-color: rgba(91, 119, 238, 0.15);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn-primary {
  background: var(--gradient-primary);
  color: var(--text-white);
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(91, 119, 238, 0.30);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  position: relative;
  overflow: hidden;
}
.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 32px rgba(91, 119, 238, 0.40);
}
.btn-primary:hover::before { opacity: 1; }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--border-color);
  padding: 12px 28px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn-secondary:hover {
  border-color: var(--primary);
  background: rgba(91, 119, 238, 0.04);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

.btn-success {
  background: linear-gradient(135deg, #22C55E 0%, #16A34A 100%);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.30);
}
.btn-success:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 28px rgba(34, 197, 94, 0.40);
}

.btn-danger {
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.30);
}
.btn-danger:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 28px rgba(239, 68, 68, 0.40);
}

.btn-warning {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}
.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
}
.btn-ghost:hover {
  background: rgba(91, 119, 238, 0.06);
  color: var(--primary);
}

.btn-refresh {
  background: var(--primary-secondary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}
.btn-refresh:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-xray {
  background: #6f42c1;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
}
.btn-xray:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(111, 66, 193, 0.3);
}

.btn-chat {
  background: var(--gradient-primary);
  color: white;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-block;
}
.btn-chat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.btn-close {
  background: #EF4444;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  margin-right: 8px;
}
.btn-close:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

/* ========================================
   INPUTS
   ======================================== */
.input-field {
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 15px;
  transition: all 0.3s ease;
  color: var(--text-primary);
  width: 100%;
  font-family: var(--font-family);
}
.input-field:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(91, 119, 238, 0.10);
  outline: none;
  background: white;
}
.input-field::placeholder { color: var(--text-light); }
.input-field:disabled { opacity: 0.6; cursor: not-allowed; }

/* ========================================
   CARDS
   ======================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid rgba(91, 119, 238, 0.08);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}
.card:hover { box-shadow: var(--shadow-md); }

/* ========================================
   BADGES
   ======================================== */
.badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}
.badge-active { background: #D1FAE5; color: #065F46; }
.badge-waiting { background: #FEF3C7; color: #92400E; }
.badge-closed { background: #FEE2E2; color: #991B1B; }
.badge-unread {
  background: var(--gradient-primary);
  color: white;
  border-radius: 50%;
  padding: 2px 8px;
  font-size: 11px;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(91, 119, 238, 0.30);
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
  background: var(--gradient-secondary);
  color: var(--text-white);
  padding: 16px 24px;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}
.app-header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-header .logo img {
  height: 40px;
  width: 40px;
  border-radius: 50% !important;
  border: 2px solid rgba(255,255,255,0.25);
  object-fit: cover;
}
.app-header .logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.app-header .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========================================
   STAT CARDS
   ======================================== */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  border: 1px solid rgba(91, 119, 238, 0.08);
  box-shadow: var(--shadow-sm);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.stat-card .stat-value {
  font-size: 2.4rem;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 8px 0;
}
.stat-card .stat-label {
  font-size: 14px;
  color: var(--text-secondary);
  -webkit-text-fill-color: var(--text-secondary);
}
.stat-card .stat-icon {
  font-size: 32px;
  margin-bottom: 8px;
  display: block;
}

/* ========================================
   CHAT
   ======================================== */
.message-customer {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
  padding: 12px 16px;
  max-width: 80%;
  align-self: flex-start;
}
.message-admin {
  background: var(--gradient-primary);
  color: var(--text-white);
  border-radius: var(--radius-md);
  border-bottom-right-radius: 4px;
  padding: 12px 16px;
  max-width: 80%;
  align-self: flex-end;
  box-shadow: 0 4px 20px rgba(91, 119, 238, 0.20);
}
.message-time {
  font-size: 10px;
  opacity: 0.7;
  margin-top: 4px;
}

/* ========================================
   TABLES
   ======================================== */
.table-container {
  overflow-x: auto;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(91, 119, 238, 0.08);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 14px 16px;
  text-align: right;
  border-bottom: 1px solid rgba(91, 119, 238, 0.06);
}
th {
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr:hover { background: rgba(91, 119, 238, 0.03); }

/* ========================================
   SESSION CLOSED BANNER
   ======================================== */
.session-closed-banner {
  background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
  color: #991B1B;
  padding: 12px 20px;
  text-align: center;
  font-weight: 600;
  border-top: 2px solid #FCA5A5;
  flex-shrink: 0;
}

/* ========================================
   LOGIN PAGE
   ======================================== */
.login-container {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  background: #EDE4FF;
  background-image: 
    radial-gradient(ellipse at 10% 20%, rgba(124, 107, 240, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse at 90% 80%, rgba(91, 119, 238, 0.10) 0%, transparent 60%);
  transition: background 0.3s ease;
}

.login-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  max-width: 480px;
  width: 100%;
  border: 1px solid rgba(91, 119, 238, 0.08);
  box-shadow: var(--shadow-xl);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-primary);
}

.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3px solid var(--border-color);
  padding: 4px;
  box-shadow: var(--shadow-sm);
  object-fit: cover;
}
.login-logo h1 {
  font-size: 28px;
  font-weight: 700;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-top: 12px;
}
.login-logo p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.action-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  background: var(--bg-card);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.sessions-list {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  overflow: hidden;
}
.sessions-list .section-title {
  padding: 16px 20px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
  color: var(--text-primary);
}
.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-card);
}
.session-item:last-child { border-bottom: none; }
.session-item:hover { background: rgba(91, 119, 238, 0.04); }

/* FORCE session-info to ALWAYS be white */
.session-info {
  background: #ffffff !important;
}

.session-info h4 {
  color: var(--text-primary);
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.session-info .session-time {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}
.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
  .app-header { padding: 12px 16px; border-radius: 0; }
  .app-header .logo h1 { font-size: 16px; }
  .stat-card .stat-value { font-size: 1.6rem; }
  .card { padding: 16px; }
  .btn-primary, .btn-secondary, .btn-success, .btn-danger {
    padding: 10px 20px;
    font-size: 13px;
  }
  .message-customer, .message-admin { max-width: 90%; }
  .login-card { padding: 32px 20px; }
}

@media (max-width: 480px) {
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 1.3rem; }
  .app-header .logo img { height: 30px; width: 30px; }
  .app-header .logo h1 { font-size: 14px; }
  .login-logo img { width: 60px; height: 60px; }
  .login-logo h1 { font-size: 22px; }
}
