
:root {
  --primary: #0d9488;
  --primary-light: #14b8a6;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --bg-dark: #0f172a;
  --bg-sidebar: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --text-white: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #cbd5e1;
  --border: #334155;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  font-family: 'Inter', sans-serif; 
  background: var(--bg-dark); 
  color: var(--text-white); 
  min-height: 100vh;
  /* Mobil Tətbiq Üçün Optimizasiyalar */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}
input, textarea, select { user-select: auto; }

/* LOGIN */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}
.login-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 48px;
  width: 400px; max-width: 90%; border: 1px solid var(--border);
  box-shadow: var(--shadow); text-align: center;
}
.login-card h1 { font-size: 1.8rem; margin-bottom: 8px; }
.login-card h1 span { color: var(--accent); }
.login-card p { color: var(--text-muted); margin-bottom: 32px; font-size: 0.9rem; }
.login-input {
  width: 100%; padding: 14px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-input);
  color: var(--text-white); font-size: 1rem; font-family: 'Inter', sans-serif;
  margin-bottom: 16px; outline: none; transition: border-color 0.3s;
}
.login-input:focus { border-color: var(--primary); }
.login-btn {
  width: 100%; padding: 14px; background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; border: none; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 1rem; font-weight: 700; font-family: 'Inter', sans-serif;
  transition: transform 0.3s, box-shadow 0.3s;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 0 20px rgba(13,148,136,0.4); }

/* ADMIN LAYOUT */
.admin-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: 260px; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 24px; font-size: 1.4rem; font-weight: 800;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px;
  border-radius: var(--radius-sm); color: var(--text-muted);
  text-decoration: none; font-weight: 500; font-size: 0.95rem;
  transition: all 0.3s; cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.sidebar-link:hover { background: rgba(255,255,255,0.05); color: var(--text-white); }
.sidebar-link.active { background: rgba(13,148,136,0.15); color: var(--primary-light); }
.sidebar-link .icon { font-size: 1.2rem; width: 24px; text-align: center; }
.sidebar-footer { padding: 16px 12px; border-top: 1px solid var(--border); }

/* MAIN CONTENT */
.main-content { flex: 1; margin-left: 260px; padding: 32px; }
.page-header { margin-bottom: 32px; }
.page-header h2 { font-size: 1.8rem; font-weight: 800; }
.page-header p { color: var(--text-muted); }

/* STAT CARDS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
.stat-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 24px;
  border: 1px solid var(--border); transition: all 0.3s;
}
.stat-card:hover { border-color: var(--primary); transform: translateY(-4px); }
.stat-card .stat-icon { font-size: 2rem; margin-bottom: 12px; }
.stat-card .stat-value {
  font-size: 2rem; font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* CARDS */
.content-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 24px;
  border: 1px solid var(--border); margin-bottom: 24px;
}
.content-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* TABLE */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 12px 16px; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
td { padding: 14px 16px; font-size: 0.9rem; border-bottom: 1px solid rgba(51,65,85,0.5); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* STATUS BADGE */
.status-badge {
  display: inline-block; padding: 4px 12px; border-radius: 50px;
  font-size: 0.75rem; font-weight: 600;
}

/* ACTION BUTTONS */
.action-btn {
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  font-size: 0.85rem; transition: all 0.3s; color: var(--text-white);
}
.action-btn:hover { background: rgba(255,255,255,0.1); }
.action-btn.danger:hover { background: rgba(239,68,68,0.2); border-color: var(--danger); }

/* FORM */
.add-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 20px; }
.add-form .form-group { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 160px; }
.add-form label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }
.add-form input, .add-form select {
  padding: 10px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text-white); font-family: 'Inter', sans-serif;
  font-size: 0.9rem; outline: none;
}
.add-form input:focus { border-color: var(--primary); }
.add-btn {
  padding: 10px 20px; background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; border: none; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-family: 'Inter', sans-serif; transition: all 0.3s;
  white-space: nowrap;
}
.add-btn:hover { transform: translateY(-2px); box-shadow: 0 0 15px rgba(13,148,136,0.3); }

/* RECENT ITEMS */
.recent-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0; border-bottom: 1px solid rgba(51,65,85,0.4);
}
.recent-item:last-child { border-bottom: none; }
.recent-info strong { display: block; font-size: 0.95rem; }
.recent-info span { font-size: 0.8rem; color: var(--text-muted); }
.recent-meta { display: flex; align-items: center; gap: 10px; }
.ref-tag { font-size: 0.75rem; color: var(--text-muted); }

/* TOP WORKERS */
.top-worker-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid rgba(51,65,85,0.3);
}
.top-worker-item:last-child { border-bottom: none; }
.rank { font-weight: 800; color: var(--accent); width: 30px; }
.tw-name { flex: 1; font-weight: 500; }
.tw-leads { color: var(--text-muted); font-size: 0.85rem; width: 70px; }
.tw-earned { font-weight: 700; color: var(--success); font-size: 0.9rem; }

/* STATUS SELECT */
.status-select {
  padding: 6px 10px; border-radius: 6px; background: var(--bg-input);
  color: var(--text-white); border: 1px solid var(--border);
  font-family: 'Inter', sans-serif; font-size: 0.85rem; outline: none;
}

/* REVENUE INPUT */
.revenue-input {
  width: 80px; padding: 6px 10px; border-radius: 6px;
  background: var(--bg-input); color: var(--text-white);
  border: 1px solid var(--border); font-family: 'Inter', sans-serif;
  font-size: 0.85rem; outline: none;
}

/* FINANCE CARDS */
.finance-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 24px; }
.fin-card {
  background: var(--bg-card); border-radius: var(--radius); padding: 24px;
  border: 1px solid var(--border); text-align: center;
}
.fin-card .fin-value { font-size: 1.8rem; font-weight: 800; margin: 8px 0 4px; }
.fin-card .fin-label { font-size: 0.85rem; color: var(--text-muted); }
.fin-card.revenue .fin-value { color: var(--info); }
.fin-card.commission .fin-value { color: var(--warning); }
.fin-card.profit .fin-value { color: var(--success); }

/* ADMIN PAGES */
.admin-page { display: none; }
.admin-page.active { display: block; }

/* POSITIONS GRID */
.positions-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

/* TOAST */
.toast {
  position: fixed; top: 24px; right: 24px; z-index: 9999;
  background: var(--bg-card); border-radius: var(--radius-sm);
  padding: 16px 24px; box-shadow: var(--shadow);
  border-left: 4px solid var(--success); color: var(--text-white);
  transform: translateX(120%); transition: transform 0.4s ease;
}
.toast.show { transform: translateX(0); }
.toast h4 { font-size: 0.95rem; margin-bottom: 4px; }
.toast p { font-size: 0.85rem; color: var(--text-muted); }

/* GRID LAYOUT */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }

/* ===== RESPONSIVE ===== */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(8px);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-admin-header {
  display: none;
}

@media (max-width: 1024px) {
  .sidebar { width: 70px; }
  .sidebar-logo { font-size: 0; padding: 16px; }
  .sidebar-link span { display: none; }
  .main-content { margin-left: 70px; }
  .grid-2 { grid-template-columns: 1fr; }
  .finance-stats { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sidebar {
    display: flex;
    position: fixed;
    top: 0; bottom: 0;
    left: -260px; /* Slide-out hide */
    width: 260px;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
    background: var(--bg-sidebar);
  }
  .sidebar.active {
    left: 0;
  }
  .sidebar-logo {
    font-size: 1.4rem !important;
    padding: 24px !important;
  }
  .sidebar-link span {
    display: inline !important;
  }
  .main-content { margin-left: 0; padding: 16px; }
  .mobile-admin-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 99;
    margin: -16px -16px 16px -16px; /* offset the main-content padding */
  }
  .menu-toggle-btn {
    background: none;
    border: none;
    color: var(--text-white);
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.3s;
  }
  .menu-toggle-btn:active {
    background: rgba(255,255,255,0.1);
  }
  .mobile-logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-white);
  }
  .mobile-logo span {
    color: var(--accent);
  }
  
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .add-form { flex-direction: column; }
  .mobile-sync-btn:active {
    background: rgba(255,255,255,0.1);
  }
}

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

