/* Modern Admin CSS with improved dark mode and responsive design */
:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --bg: #f8fafc;
  --bg-dark: #18181b;
  --text: #1e293b;
  --text-dark: #f1f5f9;
  --sidebar: #fff;
  --sidebar-dark: #27272a;
  --accent: #fbbf24;
  --sidebar-width: 220px;
  --sidebar-collapsed-width: 60px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  margin: 0;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}

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

.sidebar {
  background: var(--sidebar);
  color: var(--text);
  width: var(--sidebar-width);
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  transition: all 0.3s ease-in-out;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

body.dark .sidebar {
  background: var(--sidebar-dark);
  color: var(--text-dark);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  font-size: 1.25rem;
  font-weight: bold;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease-in-out;
}

body.dark .sidebar-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
  font-size: 1.5rem;
  color: var(--primary);
  margin: 0;
  transition: opacity 0.3s ease-in-out;
}

.sidebar.collapsed .logo {
  opacity: 0;
  visibility: hidden;
}

.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: inherit;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease-in-out;
}

.sidebar-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--primary);
}

body.dark .sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar nav ul li {
  margin: 0.5rem 0;
}

.sidebar nav ul li a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: inherit;
  text-decoration: none;
  border-radius: 0.375rem;
  margin: 0 0.5rem;
  transition: all 0.2s ease-in-out;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar nav ul li a span {
  margin-left: 0.75rem;
  transition: opacity 0.3s ease-in-out;
}

.sidebar.collapsed nav ul li a span {
  opacity: 0;
  visibility: hidden;
}

.sidebar nav ul li a:hover, .sidebar nav ul li a.active {
  background: var(--primary);
  color: #fff;
  transform: translateX(4px);
}

body.dark .sidebar nav ul li a:hover, body.dark .sidebar nav ul li a.active {
  background: var(--primary-dark);
  color: #fff;
}

.main-content {
  margin-left: var(--sidebar-width);
  padding: 2rem;
  transition: margin-left 0.3s ease-in-out;
  min-height: 100vh;
}

.main-content.expanded {
  margin-left: var(--sidebar-collapsed-width);
}

.card {
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  padding: 2rem;
  margin-bottom: 2rem;
}
body.dark .card {
  background: #23232b;
  color: var(--text-dark);
}
.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}
.table th, .table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}
body.dark .table th, body.dark .table td {
  border-bottom: 1px solid #333;
}
.table th {
  background: #f1f5f9;
  font-weight: 600;
}
body.dark .table th {
  background: #23232b;
}
.badge {
  display: inline-block;
  padding: 0.25em 0.75em;
  border-radius: 9999px;
  font-size: 0.875em;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
}
.badge-success { background: #22c55e; }
.badge-warning { background: #fbbf24; }
.badge-danger { background: #ef4444; }
.btn {
  display: inline-block;
  padding: 0.5em 1.25em;
  border-radius: 0.375rem;
  border: none;
  font-size: 1em;
  font-weight: 500;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background 0.2s;
}
.btn-secondary {
  background: #64748b;
}
.btn:hover {
  background: var(--primary-dark);
}
.btn-secondary:hover {
  background: #475569;
}
.form-group {
  margin-bottom: 1.5rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  font-size: 1em;
  background: #fff;
  color: var(--text);
  transition: border 0.2s;
}
body.dark .form-group input, body.dark .form-group select {
  background: #23232b;
  color: var(--text-dark);
  border: 1px solid #333;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--primary);
}
.login-container {
  max-width: 400px;
  margin: 5vh auto;
  padding: 2rem;
  background: #fff;
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
body.dark .login-container {
  background: #23232b;
  color: var(--text-dark);
}
.dark-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  margin-left: 1rem;
  color: var(--primary);
  z-index: 1000;
  padding: 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.2s ease-in-out;
}

.dark-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.dark .dark-toggle {
  color: var(--accent);
}

body.dark .dark-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Responsive design */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    padding: 1rem;
  }
  
  .main-content.expanded {
    margin-left: 0;
  }
}

@media (max-width: 600px) {
  .main-content {
    margin-left: 0;
    padding: 0.5rem;
  }
  
  .sidebar {
    width: 100%;
    max-width: 300px;
  }
}

/* ===== USER REWARDS ADMIN STYLES ===== */

/* Analytics Dashboard */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.analytics-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 1.5rem;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.analytics-card:hover {
    transform: translateY(-2px);
}

.analytics-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0.9;
}

.analytics-number {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.analytics-change {
    font-size: 0.8rem;
    font-weight: 500;
}

.analytics-change.positive {
    color: #4ade80;
}

.analytics-change.negative {
    color: #f87171;
}

/* Search and Filter Controls */
.search-filter-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-group {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    min-width: 300px;
}

.search-group input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
}

.filter-group select {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
}

/* User Table Styles */
.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

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

.user-email, .user-phone {
    font-size: 0.8rem;
    color: #6b7280;
}

/* Tier Badges */
.tier-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tier-green {
    background: #dcfce7;
    color: #166534;
}

.tier-silver {
    background: #f3f4f6;
    color: #374151;
}

.tier-gold {
    background: #fef3c7;
    color: #92400e;
}

.tier-platinum {
    background: linear-gradient(135deg, #e5e7eb 0%, #d1d5db 100%);
    color: #1f2937;
}

/* Points Display */
.points-display {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.points-number {
    font-weight: 600;
    font-size: 1.1rem;
    color: #059669;
}

.points-progress {
    width: 100%;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Referral Code Display */
.referral-code-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.code {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: #1f2937;
    background: #f3f4f6;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

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

.copy-icon {
    font-size: 0.9rem;
}

/* QR Code Actions */
.qr-code-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.qr-code-actions .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Referral Stats */
.referral-stats {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
}

.stat-label {
    color: #6b7280;
}

.stat-value {
    font-weight: 600;
    color: #1f2937;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.action-buttons .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    min-width: auto;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: modalSlideIn 0.3s ease;
}

.modal-content.large {
    max-width: 900px;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    margin: 0;
    color: #1f2937;
}

.close {
    color: #6b7280;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close:hover {
    color: #1f2937;
}

.modal-body {
    padding: 1.5rem;
}

/* QR Code Display in Modal */
.qr-code-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.qr-code-img {
    width: 200px;
    height: 200px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
    background: white;
}

.qr-code-info {
    text-align: center;
}

.qr-code-info p {
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

.qr-code-info strong {
    color: #1f2937;
}

/* User Details Grid */
.user-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.detail-section h4 {
    margin: 0 0 1rem 0;
    color: #1f2937;
    font-size: 1rem;
}

.history-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.85rem;
}

.history-item:last-child {
    border-bottom: none;
}

.history-date {
    color: #6b7280;
    font-size: 0.75rem;
    min-width: 80px;
}

.history-description {
    flex: 1;
    margin: 0 1rem;
    color: #1f2937;
}

.history-amount {
    font-weight: 600;
    min-width: 60px;
    text-align: right;
}

.history-amount.positive {
    color: #059669;
}

.history-amount.negative {
    color: #dc2626;
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #1f2937;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-link {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    text-decoration: none;
    color: #374151;
    transition: all 0.2s ease;
}

.page-link:hover {
    background: #f3f4f6;
}

.page-link.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.page-link.ellipsis {
    border: none;
    color: #6b7280;
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-filter-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-group {
        min-width: auto;
    }
    
    .filter-group {
        justify-content: space-between;
    }
    
    .analytics-grid {
        grid-template-columns: 1fr;
    }
    
    .user-details-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .qr-code-actions {
        flex-direction: column;
    }
}

/* Button Enhancements */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

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

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-info {
    background: #06b6d4;
    color: white;
}

.btn-info:hover {
    background: #0891b2;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    min-width: 60px;
}

/* Login page specific */
.login-error {
  display: none;
  color: #ef4444;
  margin-bottom: 1rem;
}

.login-password-group {
  position: relative;
}

.login-spinner {
  display: none;
  margin-right: 8px;
}

.login-submit-btn {
  width: 100%;
}

/* Password toggle button styles */
.password-toggle-btn {
    position: absolute;
    right: 10px;
    top: 35px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0;
    color: #6b7280;
    transition: color 0.2s ease;
}

.password-toggle-btn:hover {
    color: #374151;
}

body.dark .password-toggle-btn {
    color: #9ca3af;
}

body.dark .password-toggle-btn:hover {
    color: #d1d5db;
}
