/* ============================================
   Ambika4u - Global Styles
   ============================================ */

:root {
  --primary: #6c63ff;
  --primary-dark: #5a52d5;
  --secondary: #f093fb;
  --accent: #4facfe;
  --success: #43e97b;
  --warning: #f6d365;
  --danger: #fa709a;
  --dark: #1a1a2e;
  --dark-2: #16213e;
  --dark-3: #0f3460;
  --text: #2d3748;
  --text-light: #718096;
  --bg: #f7f8fc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --shadow: 0 4px 20px rgba(108, 99, 255, 0.1);
  --shadow-hover: 0 8px 30px rgba(108, 99, 255, 0.2);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.3s ease;
  --font: 'Poppins', sans-serif;
}

[data-theme="dark"] {
  --text: #e2e8f0;
  --text-light: #a0aec0;
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --border: #2d3748;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 8px 30px rgba(108, 99, 255, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

a {
  text-decoration: none;
  color: var(--primary);
  transition: var(--transition);
}

a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; }

ul { list-style: none; }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
}

.btn-success {
  background: var(--success);
  color: #fff;
  border-color: var(--success);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-warning {
  background: var(--warning);
  color: var(--dark);
  border-color: var(--warning);
}

.btn-sm {
  padding: 6px 16px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-4px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg-card);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

.form-control::placeholder { color: var(--text-light); }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c63ff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.form-error {
  color: var(--danger);
  font-size: 0.8rem;
  margin-top: 4px;
}

.form-hint {
  color: var(--text-light);
  font-size: 0.8rem;
  margin-top: 4px;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-free { background: rgba(67, 233, 123, 0.15); color: #27ae60; }
.badge-premium { background: rgba(246, 211, 101, 0.2); color: #e67e22; }
.badge-success { background: rgba(67, 233, 123, 0.15); color: #27ae60; }
.badge-danger { background: rgba(250, 112, 154, 0.15); color: #e74c3c; }
.badge-info { background: rgba(79, 172, 254, 0.15); color: #2980b9; }

/* ============================================
   ALERTS
   ============================================ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.alert-success { background: rgba(67, 233, 123, 0.1); color: #27ae60; border: 1px solid rgba(67, 233, 123, 0.3); }
.alert-danger { background: rgba(250, 112, 154, 0.1); color: #e74c3c; border: 1px solid rgba(250, 112, 154, 0.3); }
.alert-warning { background: rgba(246, 211, 101, 0.1); color: #e67e22; border: 1px solid rgba(246, 211, 101, 0.3); }
.alert-info { background: rgba(79, 172, 254, 0.1); color: #2980b9; border: 1px solid rgba(79, 172, 254, 0.3); }

/* ============================================
   LAYOUT
   ============================================ */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.container-sm { max-width: 600px; }
.container-md { max-width: 800px; }

.section {
  padding: 60px 0;
}

.section-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.section-subtitle {
  color: var(--text-light);
  font-size: 1rem;
  margin-bottom: 40px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }

/* ============================================
   NOTIFICATION BAR
   ============================================ */
.notification-bar {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  overflow: hidden;
  position: relative;
  z-index: 1001;
}

.notif-scroll {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
  animation: scrollText 30s linear infinite;
}

.notif-item {
  display: inline-block;
  margin-right: 60px;
  font-size: 0.85rem;
}

.notif-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 8px;
  opacity: 0.8;
}

@keyframes scrollText {
  0% { transform: translateX(100%); }
  100% { transform: translateX(-100%); }
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
  background: var(--dark);
  color: #a0aec0;
  padding: 60px 0 0;
  margin-top: 0;
}

/* On mobile, add extra bottom margin so footer clears the bottom nav */
@media (max-width: 600px) {
  .footer { margin-bottom: 0; padding-bottom: 70px; }
}

.footer-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.5fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  display: block;
  margin-bottom: 16px;
}

.footer-logo span { color: var(--primary); }

.footer-brand p { font-size: 0.9rem; line-height: 1.7; margin-bottom: 20px; }

.social-links { display: flex; gap: 12px; }
.social-links a {
  width: 38px; height: 38px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.9rem;
  transition: var(--transition);
}
.social-links a:hover { background: var(--primary); transform: translateY(-3px); }

.footer-links h4, .footer-contact h4 {
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.footer-links ul li { margin-bottom: 10px; }
.footer-links ul li a { color: #a0aec0; font-size: 0.9rem; }
.footer-links ul li a:hover { color: var(--primary); padding-left: 4px; }

.footer-contact p { font-size: 0.9rem; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }

.footer-bottom {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding: 20px 0;
  text-align: center;
  font-size: 0.85rem;
}

.footer-bottom a { color: var(--primary); }

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================
   PROGRESS BAR
   ============================================ */
.progress {
  background: var(--border);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 20px;
  transition: width 0.5s ease;
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 500px;
  width: 100%;
  transform: scale(0.9);
  transition: var(--transition);
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}

.modal-close {
  background: none; border: none;
  font-size: 1.4rem; cursor: pointer;
  color: var(--text-light);
  transition: var(--transition);
}
.modal-close:hover { color: var(--danger); }

/* ============================================
   TABLES
   ============================================ */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th {
  background: var(--bg);
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tr:hover td { background: rgba(108, 99, 255, 0.03); }

/* ============================================
   PAGINATION
   ============================================ */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; margin-top: 30px;
}

.page-btn {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
}

.page-btn:hover, .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .section { padding: 40px 0; }
  .section-title { font-size: 1.5rem; }
  .footer-grid { grid-template-columns: 1fr; gap: 30px; }
}

@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .btn { padding: 9px 18px; font-size: 0.85rem; }
}

/* ============================================
   MOBILE FIXES — Global
   ============================================ */

/* Notification bar — scrolling text on mobile */
@media (max-width: 600px) {
  .notification-bar {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  .notif-item {
    font-size: 0.78rem;
  }
}

/* Footer — single column on mobile */
@media (max-width: 600px) {
  .footer-grid {
    grid-template-columns: 1fr !important;
    gap: 24px;
  }

  .footer { padding: 32px 0 0; }
}

/* Prevent horizontal overflow globally */
@media (max-width: 600px) {
  body { overflow-x: hidden; }

  .container { padding: 0 12px; }

  /* Grid helpers — force single column on mobile */
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr !important;
  }

  /* Buttons in flex rows — wrap */
  .btn-group,
  div[style*="display:flex"][style*="gap"] {
    flex-wrap: wrap;
  }

  /* Section padding */
  .section { padding: 28px 0; }
  .section-title { font-size: 1.3rem; }
}

/* ============================================
   MOBILE FIXES — All Pages Universal
   ============================================ */

/* Prevent any element from causing horizontal scroll */
@media (max-width: 600px) {
  * {
    max-width: 100%;
  }

  /* Images never overflow */
  img { max-width: 100%; height: auto; }

  /* Tables always scrollable */
  .table-wrapper,
  div[style*="overflow-x:auto"] {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* All flex rows wrap */
  .card-header,
  .card-header > div {
    flex-wrap: wrap;
  }

  /* Section headings */
  .section-title { font-size: 1.3rem; }
  .section-subtitle { font-size: 0.88rem; }

  /* Container padding */
  .container { padding: 0 12px; }

  /* Cards */
  .card { padding: 16px; }

  /* Modals — full width */
  .modal {
    max-width: calc(100vw - 24px) !important;
    margin: 0 12px;
    padding: 20px 16px;
  }

  /* Pagination — wrap */
  .pagination { flex-wrap: wrap; gap: 4px; }
  .page-btn { min-width: 32px; height: 32px; font-size: 0.8rem; }

  /* Alert — smaller */
  .alert { font-size: 0.82rem; padding: 10px 14px; }

  /* Badges — don't overflow */
  .badge { white-space: nowrap; }

  /* Buttons in inline flex containers */
  .btn { white-space: nowrap; }

  /* Footer bottom — stack */
  .footer-bottom p {
    flex-direction: column !important;
    gap: 8px !important;
    text-align: center;
  }
}

/* Very small screens (320px) */
@media (max-width: 360px) {
  .container { padding: 0 10px; }
  .card { padding: 12px; }
  .btn { padding: 8px 14px; font-size: 0.8rem; }
  .section-title { font-size: 1.2rem; }
}

/* ============================================
   SMOOTH SCROLL — All pages
   ============================================ */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   HIDE DEFAULT SCROLLBAR — JS custom one use hoga
   ============================================ */
html::-webkit-scrollbar { display: none; }
html { -ms-overflow-style: none; scrollbar-width: none; }

/* Inner panels — thin native scrollbar */
.notif-dropdown-body,
.sidebar,
.admin-sidebar,
.table-wrapper,
.nav-menu {
  scrollbar-width: thin;
  scrollbar-color: #6c63ff transparent;
}

.notif-dropdown-body::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.admin-sidebar::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
  width: 3px;
  height: 3px;
  display: block;
}

.notif-dropdown-body::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.admin-sidebar::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
  background: #6c63ff;
  border-radius: 10px;
}

/* ============================================
   CUSTOM SCROLLBAR ELEMENT (injected by JS)
   ============================================ */
#customScrollbar {
  position: fixed;
  right: 0;
  top: 0;
  width: 6px;
  height: 100vh;
  z-index: 99998;
  pointer-events: auto;
  cursor: pointer;
}

#customScrollTrack {
  position: absolute;
  right: 0;
  top: 0;
  width: 6px;
  height: 100%;
  background: rgba(108, 99, 255, 0.08);
  border-radius: 10px;
}

#customScrollThumb {
  position: absolute;
  right: 0;
  top: 0;
  width: 6px;
  border-radius: 10px;
  background: linear-gradient(180deg, #6c63ff 0%, #f093fb 50%, #4facfe 100%);
  box-shadow:
    0 0 8px rgba(108, 99, 255, 0.7),
    0 0 16px rgba(240, 147, 251, 0.4);
  transition: width 0.2s ease, right 0.2s ease;
  min-height: 40px;
  cursor: grab;
}

#customScrollThumb:active {
  cursor: grabbing;
}

#customScrollThumb.wide {
  width: 10px;
  right: -2px;
  box-shadow:
    0 0 12px rgba(108, 99, 255, 0.9),
    0 0 24px rgba(240, 147, 251, 0.6);
}

/* Pulse ring on scroll */
#scrollPulse {
  position: fixed;
  right: -4px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(108, 99, 255, 0.4);
  pointer-events: none;
  z-index: 99997;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.1s, transform 0.1s;
}

#scrollPulse.active {
  opacity: 1;
  transform: scale(1);
  animation: pulseRing 0.6s ease-out forwards;
}

@keyframes pulseRing {
  0%   { transform: scale(0.5); opacity: 0.8; }
  100% { transform: scale(2.5); opacity: 0; }
}
