/* ============================================================
   CALCIFY DESIGN SYSTEM — common.css (PHASE 2: FRESH LOOK)
   A high-end, modern aesthetic featuring glassmorphism,
   depth, and vibrant gradients.
   ============================================================ */

/* ── Google Fonts ── */
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap");

/* ============================================================
   1. THEME VARIABLES
   ============================================================ */

:root {
  /* ── Brand ── */
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --accent-glow: rgba(245, 158, 11, 0.35);
  --accent-gradient: linear-gradient(135deg, #f59e0b 0%, #ea580c 100%);
  --accent-gradient-hover: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);

  /* ── Light theme (Fresh) ── */
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.8);
  --bg-card-hover: rgba(255, 255, 255, 0.95);
  --bg-input: #f1f5f9;
  --bg-nav: rgba(255, 255, 255, 0.75);
  --bg-toast: #0f172a;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --border-color: rgba(226, 232, 240, 0.8);
  --border-hover: rgba(203, 213, 225, 1);
  --glass-border: rgba(255, 255, 255, 0.5);
  --inner-glow: rgba(255, 255, 255, 0.4);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --shadow-deep: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ── Dark theme (Deep Space) ── */
[data-theme="dark"] {
  --bg-primary: #020617; /* Deepest Navy */
  --bg-secondary: #0f172a; /* Slate 900 */
  --bg-card: rgba(15, 23, 42, 0.7);
  --bg-card-hover: rgba(30, 41, 59, 0.8);
  --bg-input: #1e293b;
  --bg-nav: rgba(2, 6, 23, 0.8);
  --bg-toast: #f8fafc;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #020617;

  --border-color: rgba(30, 41, 59, 0.8);
  --border-hover: rgba(51, 65, 85, 1);
  --glass-border: rgba(255, 255, 255, 0.1);
  --inner-glow: rgba(255, 255, 255, 0.05);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --shadow-deep: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

/* ============================================================
   2. BASE STYLES
   ============================================================ */

* {
  box-sizing: border-box;
}

body {
  font-family: Poppins, "Inter", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: background-color 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Poppins", sans-serif;
  letter-spacing: -0.02em;
}

main {
  flex: 1 0 auto;
  margin-top: 72px; /* offset for fixed navbar */
}

footer {
  flex-shrink: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-hover);
}

::selection {
  background-color: var(--accent);
  color: white;
}

/* ============================================================
   3. NAVBAR
   ============================================================ */

.navbar-custom {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  background: var(--bg-nav);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  transition:
    background 0.3s ease,
    border-color 0.3s ease;
}

.nav-link-custom {
  position: relative;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  transition:
    color 0.2s ease,
    background-color 0.2s ease;
}

.nav-link-custom:hover {
  color: var(--accent);
  background-color: var(--bg-card-hover);
}

.nav-link-custom.active {
  color: var(--accent);
  font-weight: 600;
}

.nav-link-custom.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* ============================================================
   3. MOBILE NAVIGATION (OFFCANVAS)
   ============================================================ */

.mobile-nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.4s ease;
}

.mobile-nav-overlay.open {
  opacity: 1;
  visibility: visible;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: min(310px, 85vw);
  height: 100dvh;
  background: var(--bg-nav);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  z-index: 2010;
  transform: translateX(-100%);
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 20px 0 50px rgba(0, 0, 0, 0.1);
  border-right: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.mobile-nav-drawer.open {
  transform: translateX(0);
}

/* Accordion / Expandable Categories */
.nav-category-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.875rem 1rem;
  border-radius: 0.75rem;
  color: var(--text-primary);
  font-weight: 600;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.nav-category-btn:hover {
  background: var(--accent-glow);
  color: var(--accent);
  padding-left: 1.25rem;
}

.nav-category-btn:active {
  transform: scale(0.98);
}

.nav-category-icon {
  font-size: 0.75rem;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  opacity: 0.5;
}

.nav-category-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  padding-left: 1rem;
}

.nav-category-content.open {
  margin-bottom: 0.75rem;
}

.nav-sub-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  border-radius: 0.75rem;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 2px;
}

.nav-sub-link:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
  transform: translateX(8px);
  box-shadow: 
    inset 0 1px 1px var(--inner-glow),
    0 4px 12px rgba(0,0,0,0.05);
}

/* ============================================================
   4. CARDS & CONTAINERS
   ============================================================ */

.card-custom {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  box-shadow: var(--shadow-md);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-custom:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.card-fresh {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: 
    inset 0 1px 1px var(--inner-glow),
    var(--shadow-lg);
  border-radius: 2rem;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.card-fresh:hover {
  transform: translateY(-8px) scale(1.01);
  box-shadow: 
    inset 0 1px 1px var(--inner-glow),
    0 20px 40px -10px rgba(0,0,0,0.2);
}

.glass-nav {
  background: var(--bg-nav);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: inset 0 -1px 0 var(--inner-glow);
}

/* ============================================================
   5. BUTTONS
   ============================================================ */

.btn-primary-custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--accent-gradient);
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
  border: none;
  border-radius: 1rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px -1px var(--accent-glow);
  position: relative;
  overflow: hidden;
}

.btn-primary-custom:hover {
  background: var(--accent-gradient-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px -1px var(--accent-glow);
}

.btn-primary-custom::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: 0.5s;
}

.btn-primary-custom:hover::after {
  left: 100%;
}

.btn-outline-custom {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline-custom:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ghost:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

/* ============================================================
   6. INPUTS
   ============================================================ */

.input-custom {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
  outline: none;
}

.input-custom:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-custom::placeholder {
  color: var(--text-muted);
}

.select-custom {
  padding: 0.625rem 2.25rem 0.625rem 1rem;
  background: var(--bg-input);
  border: 2px solid var(--border-color);
  border-radius: 0.75rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23f59e0b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.75rem center;
  background-repeat: no-repeat;
  background-size: 1.25rem;
  transition: all 0.2s ease;
}

.select-custom:hover {
  border-color: var(--accent);
  background-color: var(--bg-card-hover);
}

.select-custom:focus {
  border-color: var(--accent);
}

/* ============================================================
   7. FLOATING ACTION BUTTONS (Scroll)
   ============================================================ */

#topbtn,
#bottombtn {
  position: fixed;
  right: 24px;
  z-index: 1030;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  will-change: opacity, visibility;
}

#topbtn {
  bottom: 80px;
}

#bottombtn {
  bottom: 28px;
}

#topbtn:hover,
#bottombtn:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.1);
}

.show-btn {
  opacity: 1 !important;
  visibility: visible !important;
}

/* ============================================================
   8. PROGRESS BAR
   ============================================================ */

.progress-bar-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 1040;
  background: transparent;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #fbbf24);
  transition: width 0.1s linear;
  will-change: width;
  border-radius: 0 2px 2px 0;
}

/* ============================================================
   9. TOAST NOTIFICATIONS (Custom — no Bootstrap)
   ============================================================ */

.toast-container-custom {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

.toast-custom {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: var(--bg-toast);
  color: var(--text-inverse);
  border-radius: 12px;
  box-shadow: var(--shadow-xl);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  animation: toast-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast-custom.toast-out {
  animation: toast-out 0.2s ease-in forwards;
}

.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  padding: 4px;
  font-size: 1rem;
  line-height: 1;
  transition: opacity 0.2s;
}

.toast-close:hover {
  opacity: 1;
}

/* Toast type colors */
.toast-success {
  border-left: 4px solid #22c55e;
}

.toast-error {
  border-left: 4px solid #ef4444;
}

.toast-warning {
  border-left: 4px solid #f59e0b;
}

.toast-info {
  border-left: 4px solid #3b82f6;
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }
}

/* ============================================================
   10. INSTALL / APK BUTTON
   ============================================================ */

#installAppBtn,
#downloadApkFallback {
  position: relative;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  white-space: nowrap;
}

.animate-install-ready {
  opacity: 1 !important;
  transform: scale(1) !important;
}

.shimmer-loop::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: shimmer 2.5s infinite;
}

@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* ============================================================
   11. SECTION DIVIDER
   ============================================================ */

.divider {
  margin: 1.5rem auto;
  width: 60px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

/* ============================================================
   12. SCROLLBAR
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================================
   13. UTILITY ANIMATIONS
   ============================================================ */

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.animate-fade-in {
  animation: fade-in 0.4s ease-out;
}

.animate-fade-in-up {
  animation: fade-in-up 0.5s ease-out;
}

/* Staggered card animations */
.stagger-1 {
  animation-delay: 0.05s;
}
.stagger-2 {
  animation-delay: 0.1s;
}
.stagger-3 {
  animation-delay: 0.15s;
}
.stagger-4 {
  animation-delay: 0.2s;
}

/* ============================================================
   14. FOOTER
   ============================================================ */

.footer-custom {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition:
    background-color 0.3s ease,
    border-color 0.3s ease;
}

.footer-custom a {
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.footer-custom a:hover {
  color: var(--accent);
}

.social-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.social-link:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  transform: translateY(-2px);
}

/* ============================================================
   15. TABLE STYLES
   ============================================================ */

.table-custom {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.table-custom th {
  background: var(--bg-input);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table-custom td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-primary);
}

.table-custom tbody tr:hover {
  background-color: var(--bg-card-hover);
}

/* ============================================================
   16. RESPONSIVE HELPERS
   ============================================================ */

@media (max-width: 640px) {
  main {
    margin-top: 64px;
  }
}

/* ============================================================
   17. MODALS (Glassmorphism)
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none; /* Controlled by .active */
  align-items: center;
  justify-content: center;
  z-index: 3000;
  padding: 1.25rem;
  opacity: 0;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  visibility: hidden;
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: 2rem;
  width: 100%;
  max-width: var(--modal-width, 700px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-deep);
  animation: modalPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
  position: relative;
}

@keyframes modalPop {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: var(--bg-input);
  border: none;
  border-radius: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--accent);
  transform: rotate(90deg);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-secondary);
  gap: 0.75rem;
}

/* ============================================================
   18. CUSTOM SCROLLBARS
   ============================================================ */

.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

/* ============================================================
   19. PREMIUM SEGMENTED THEME SWITCHER
   ============================================================ */

.theme-switch-segmented {
  display: inline-flex;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 3px;
  position: relative;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-switch-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: 9999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.theme-switch-btn i {
  font-size: 0.875rem;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.theme-switch-btn:hover {
  color: var(--text-primary);
}

.theme-switch-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 12px var(--accent-glow);
}

.theme-switch-btn.active i {
  transform: scale(1.1) rotate(5deg);
}

/* Mobile responsive adjustments */
@media (max-width: 640px) {
  .theme-switch-btn {
    padding: 8px 12px;
    font-size: 0.8125rem;
  }
}
