/* ==========================================================================
   Base Styles
   ========================================================================== */

:root {
  --status-active: #10b981;
  --status-pending: #f59e0b;
  --status-inactive: #ef4444;
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body {
  background: var(--primary-gradient);
  font-family: 'Vazirmatn', 'IRANSans', Tahoma, sans-serif;
  min-height: 100vh;
}

/* ==========================================================================
   Auth Card (Login & Verify Pages)
   ========================================================================== */

.auth-card {
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  overflow: hidden;
}

.auth-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 2rem;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
}

.brand-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  margin-bottom: 1rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0 0 0.5rem 0;
}

.auth-subtitle {
  color: #6b7280;
  font-size: 0.875rem;
  margin: 0;
}

.phone-number {
  color: #1f2937;
  font-weight: 600;
  direction: ltr;
  display: inline-block;
}

.auth-body {
  padding: 2rem;
}

.auth-footer {
  text-align: center;
  padding: 1.5rem 2rem;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
}

.auth-footer a {
  color: #667eea;
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Form Elements
   ========================================================================== */

.form-label {
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.5rem;
}

.form-control {
  border-radius: 12px;
  border: 2px solid #e5e7eb;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  transition: all 0.2s;
}

.form-control:focus {
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.country-code {
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  text-align: center;
  font-weight: 600;
  color: #6b7280;
}

.form-text {
  color: #9ca3af;
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

.otp-input {
  text-align: center;
  letter-spacing: 0.5em;
  font-weight: 700;
  font-size: 1.5rem;
  padding: 1rem;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn-primary-custom {
  background: var(--primary-gradient);
  border: none;
  border-radius: 12px;
  padding: 0.875rem;
  font-weight: 600;
  color: white;
  width: 100%;
  margin-top: 1.5rem;
  transition: all 0.2s;
}

.btn-primary-custom:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
  color: white;
}

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert-danger {
  background: #fee2e2;
  border: none;
  border-radius: 12px;
  color: #991b1b;
  font-size: 0.875rem;
}

/* ==========================================================================
   Countdown & Resend (Verify Page)
   ========================================================================== */

.countdown-section {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}

.countdown-text {
  color: #6b7280;
  font-size: 0.875rem;
}

.countdown-timer {
  color: #667eea;
  font-weight: 700;
  font-size: 1.1rem;
  direction: ltr;
  display: inline-block;
}

.resend-btn {
  background: none;
  border: none;
  color: #667eea;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  transition: all 0.2s;
  display: none;
}

.resend-btn:hover {
  background: #f3f4f6;
}

.resend-btn.active {
  display: inline-block;
}

/* ==========================================================================
   Profile Card (Home Page)
   ========================================================================== */

.profile-card {
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  overflow: hidden;
}

.profile-header {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding: 2rem;
  border-bottom: 1px solid #e5e7eb;
}

.profile-photo-wrapper {
  position: relative;
  width: 88px;
  height: 88px;
}

.profile-photo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #ffffff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  position: absolute;
  top: 4px;
  right: 4px;
}

.status-ring {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 3px solid;
  position: absolute;
  top: 0;
  right: 0;
  animation: pulse 2s ease-in-out infinite;
}

.status-ring.active { border-color: var(--status-active); }
.status-ring.pending { border-color: var(--status-pending); }
.status-ring.inactive { border-color: var(--status-inactive); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.05); }
}

.profile-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

/* ==========================================================================
   Info Section (Home Page)
   ========================================================================== */

.info-section {
  padding: 1.5rem 2rem;
  border-bottom: 1px solid #f3f4f6;
}

.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.info-row:last-child {
  margin-bottom: 0;
}

.info-label {
  color: #6b7280;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  color: #111827;
  font-size: 1rem;
  font-weight: 600;
}

/* ==========================================================================
   Status Badges
   ========================================================================== */

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.875rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}

.status-badge.active {
  background: #d1fae5;
  color: #065f46;
}

.status-badge.pending {
  background: #fef3c7;
  color: #92400e;
  cursor: pointer;
}

.status-badge.pending:hover {
  background: #fde68a;
  transform: translateY(-1px);
}

.status-badge.inactive {
  background: #fee2e2;
  color: #991b1b;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* ==========================================================================
   Referral Code & Level Badge
   ========================================================================== */

.referral-code {
  background: #f3f4f6;
  color: #6b7280;
  padding: 0.5rem 1.25rem;
  border-radius: 12px;
  font-family: 'Vazirmatn', 'IRANSans', monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.referral-code:hover {
  background: #e5e7eb;
}

.referral-code.copied {
  background: #d1fae5;
  color: #065f46;
}

.level-badge {
  background: #f3f4f6;
  color: #6b7280;
  padding: 0.5rem 1.25rem;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
}

/* ==========================================================================
   Toast Notification
   ========================================================================== */

.toast-notification {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1f2937;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
}

.toast-notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ==========================================================================
   Metrics Section (Home Page)
   ========================================================================== */

.metrics-section {
  padding: 2rem;
  background: #f9fafb;
}

.metric-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem 0.75rem;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: all 0.3s;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100px;
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.metric-label {
  color: #6b7280;
  font-size: 0.7rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  letter-spacing: 0.3px;
  line-height: 1.3;
}

.metric-value {
  color: #111827;
  font-size: 1.5rem;
  font-weight: 800;
}

/* ==========================================================================
   Comparison Table (Home Page)
   ========================================================================== */

.comparison-section {
  padding: 2rem;
  background: white;
  border-top: 1px solid #e5e7eb;
}

.comparison-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.comparison-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
  text-align: center;
}

.last-updated {
  font-size: 0.75rem;
  color: #9ca3af;
}

.refresh-icon {
  color: #667eea;
}

.refresh-icon:hover {
  color: #4338ca;
}

.comparison-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.comparison-table thead {
  background: var(--primary-gradient);
}

.comparison-table th {
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 1rem 0.75rem;
  text-align: center;
}

.comparison-table tbody tr {
  background: #ffffff;
  transition: background 0.2s;
}

.comparison-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.comparison-table tbody tr:hover {
  background: #f3f4f6;
}

.comparison-table td {
  padding: 1rem 0.75rem;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
  font-size: 0.875rem;
}

.comparison-table tbody tr:last-child td {
  border-bottom: none;
}

.level-name {
  font-weight: 600;
  color: #1f2937;
}

.percent-badge {
  display: inline-block;
  background: #e0e7ff;
  color: #4338ca;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8rem;
}

.revenue-value {
  font-weight: 700;
  color: #059669;
}

.unknown-value {
  color: #9ca3af;
  font-weight: 600;
}

.current-level {
  background: #e0e7ff !important;
  font-weight: 700;
}

/* ==========================================================================
   Logout Button
   ========================================================================== */

.logout-btn {
  background: white;
  border: 2px solid #e5e7eb;
  color: #374151;
  font-weight: 600;
  padding: 0.875rem;
  border-radius: 0 0 24px 24px;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  color: #111827;
}

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

@media (max-width: 576px) {
  .profile-header {
    padding: 1.5rem;
  }

  .profile-name {
    font-size: 1.25rem;
  }

  .info-section {
    padding: 1rem 1.5rem;
  }

  .metrics-section {
    padding: 1.5rem;
  }

  .metric-card {
    padding: 0.75rem 0.5rem;
    min-height: 85px;
  }

  .metric-label {
    font-size: 0.65rem;
  }

  .metric-value {
    font-size: 1.25rem;
  }

  .comparison-section {
    padding: 1.5rem;
  }

  .comparison-table th,
  .comparison-table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.75rem;
  }

  .percent-badge {
    padding: 0.2rem 0.5rem;
    font-size: 0.7rem;
  }
}

/* ==========================================================================
   Management Panel Styles
   ========================================================================== */

.management-body {
  background: #f3f4f6;
  min-height: 100vh;
}

.management-header {
  background: var(--primary-gradient);
  padding: 1rem 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.management-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: white;
  margin: 0;
}

.manager-name {
  background: rgba(255,255,255,0.2);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
}

.management-main {
  padding: 1.5rem;
}

.messages-container {
  margin-bottom: 1rem;
}

.actions-bar {
  background: white;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.users-count {
  color: #6b7280;
  font-size: 0.9rem;
}

.users-count strong {
  color: #1f2937;
  font-size: 1.25rem;
}

.table-container {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.management-table {
  width: 100%;
  border-collapse: collapse;
}

.management-table thead {
  background: #1f2937;
}

.management-table th {
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 1rem;
  text-align: center;
  white-space: nowrap;
}

.management-table tbody tr {
  border-bottom: 1px solid #e5e7eb;
  transition: background 0.15s;
}

.management-table tbody tr:last-child {
  border-bottom: none;
}

.management-table tbody tr:hover {
  background: #f9fafb;
}

.management-table td {
  padding: 0.875rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: #374151;
}

.management-table .user-name {
  font-weight: 600;
  color: #1f2937;
  text-align: right;
}

.management-table .user-phone {
  font-family: monospace;
  color: #6b7280;
}

/* Editable Cells */
.editable-cell {
  display: inline-block;
  padding: 0.375rem 0.75rem;
  background: #f3f4f6;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 60px;
  font-weight: 600;
  color: #059669;
}

.editable-cell:hover {
  background: #e0e7ff;
  color: #4338ca;
}

.inline-edit-input {
  border: 2px solid #667eea;
  border-radius: 8px;
  padding: 0.375rem 0.75rem;
  font-size: 0.9rem;
  text-align: center;
  outline: none;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(102,126,234,0.3);
}

/* Attention Light */
.attention-light {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #d1d5db;
  margin: 0 auto;
  transition: all 0.3s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer;
}

.attention-light:hover {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.attention-light.active {
  background: #f59e0b;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.6), 0 2px 4px rgba(0,0,0,0.1);
  animation: pulse-light 2s ease-in-out infinite;
}

.attention-light.active:hover {
  background: #dc8a0a;
}

@keyframes pulse-light {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.1);
  }
}

/* Modal Styles */
.modal-content {
  border: none;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-header {
  border-bottom: 1px solid #e5e7eb;
  padding: 1.25rem 1.5rem;
}

.modal-title {
  font-weight: 700;
  color: #1f2937;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid #e5e7eb;
  padding: 1rem 1.5rem;
}

.manager-icon {
  margin-bottom: 1rem;
}

/* Responsive Management */
@media (max-width: 768px) {
  .management-main {
    padding: 1rem;
  }

  .table-container {
    overflow-x: auto;
  }

  .management-table th,
  .management-table td {
    padding: 0.75rem 0.5rem;
    font-size: 0.8rem;
  }

  .editable-cell {
    padding: 0.25rem 0.5rem;
    min-width: 50px;
    font-size: 0.85rem;
  }
}
