/**
 * Subscription Modal Styles
 * Modern dark theme with smooth animations — NO CUTOFF on short viewports
 */

/* ===== Tokens ===== */
:root {
  --subs-safe-pad: clamp(12px, 2.5dvh, 24px);
  --subs-max-w: 1200px;
}

/* ===== Modal Backdrop ===== */
.subscription-modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;                 /* toggled with .show */
  align-items: center;
  justify-content: center;
  z-index: 9999;

  /* Let the overlay itself scroll if content is tall */
  overflow: auto;
  padding: var(--subs-safe-pad);

  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.subscription-modal-backdrop.show {
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ===== Modal Container (outer shell) ===== */
.subscription-modal {
  position: relative;
  width: min(90%, var(--subs-max-w));
  /* No height cap here; the CONTENT will be capped */
  transform: scale(0.9) translateY(50px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.subscription-modal.show {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* ===== Modal Content (actual card) =====
   Turn into a 3-row grid so only the body scrolls */
.subscription-modal-content {
  background: linear-gradient(135deg, rgba(35, 44, 47, 0.95) 0%, rgba(33, 34, 44, 0.95) 100%);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(58, 65, 73, 0.3);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  overflow: hidden;

  /* KEY: cap the card by the visible viewport minus safe padding */
  max-height: calc(100dvh - (var(--subs-safe-pad) * 2));
  display: grid;
  grid-template-rows: auto 1fr auto; /* header | scrollable body | footer */
}

/* ===== Header ===== */
.subscription-modal-header {
  padding: 30px 30px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: none;
}
.subscription-modal-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  background: linear-gradient(135deg, #ffffff 0%, #e0e0e0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
/* Close stays reachable as the body scrolls */
.subscription-modal-close {
  position: sticky;
  top: 10px;
  margin-left: auto;
  z-index: 2;

  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer; transition: all 0.3s ease;
}
.subscription-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: rotate(90deg);
}

/* ===== Scrollable Body ===== */
.subscription-modal-body {
  padding: 40px 30px;
  overflow: auto;      /* ONLY the body scrolls */
  min-height: 0;       /* critical for grid child to shrink properly */
}

/* ===== Plans Container ===== */
.subscription-plans-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 30px;
  margin-bottom: 40px;
}

/* ===== Cards ===== */
.subscription-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 30px;
  border: 1px solid rgba(58, 65, 73, 0.3);
  position: relative;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  display: flex;
  flex-direction: column;
  height: 100%;
}
.subscription-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  border-color: rgba(58, 65, 73, 0.5);
}
.subscription-card.free-plan { background: rgba(255, 255, 255, 0.03); }
.subscription-card.premium-plan {
  background: linear-gradient(135deg, rgba(58, 65, 73, 0.2) 0%, rgba(58, 65, 73, 0.1) 100%);
  border-color: rgba(58, 65, 73, 0.5);
  box-shadow: 0 10px 30px rgba(58, 65, 73, 0.2);
}
.subscription-card.premium-plan:hover {
  transform: translateY(-8px);
  box-shadow: 0 25px 50px rgba(58, 65, 73, 0.3);
  border-color: rgba(58, 65, 73, 0.7);
}
.subscription-card.active-plan {
  background: rgba(58, 65, 73, 0.3);
  border-color: rgba(58, 65, 73, 0.6);
}

/* ===== Badges / Headers ===== */
.plan-badge {
  position: absolute;
  top: -12px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #3a414c 0%, #36454F 100%);
  color: white; padding: 6px 20px; border-radius: 20px;
  font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
  box-shadow: 0 4px 12px rgba(58, 65, 73, 0.3);
}
.plan-header { text-align: center; margin-bottom: 30px; }
.plan-name {
  font-size: 1.8rem; font-weight: 700; color:#fff; margin: 0 0 15px 0;
}

/* ===== Billing Toggle ===== */
.billing-toggle {
  display: flex; gap: 8px; justify-content: center; margin: 15px 0 20px;
  padding: 4px; background: rgba(255, 255, 255, 0.05);
  border-radius: 12px; width: fit-content; margin-left:auto; margin-right:auto;
}
.toggle-btn {
  background: transparent; border: none; color: rgba(255,255,255,0.6);
  padding: 10px 20px; border-radius: 8px; font-size: .95rem; font-weight: 600;
  cursor: pointer; transition: all .3s ease; position: relative;
  display: flex; align-items: center; gap: 6px;
}
.toggle-btn:hover { color: rgba(255,255,255,0.8); }
.toggle-btn.active {
  background: rgba(255,255,255,0.15); color:#fff;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.save-badge {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color:#fff; font-size:.7rem; padding:2px 6px; border-radius:4px;
  font-weight:700; text-transform:uppercase; letter-spacing:.5px;
}

/* ===== Price / Features ===== */
.plan-price {
  display:flex; align-items:baseline; justify-content:center; gap:5px;
}
.price-amount { font-size: 3rem; font-weight:700; color:#fff; transition: all .3s ease; }
.price-period { font-size: 1.1rem; color: rgba(255,255,255,.6); transition: all .3s ease; }
.yearly-savings { margin-top:8px; text-align:center; color:#10b981; font-weight:600; }
.yearly-savings small { font-size:.9rem; }

.plan-features { flex:1; margin-bottom:30px; }
.plan-features ul { list-style:none; padding:0; margin:0; }
.plan-features li {
  padding:12px 0; color: rgba(255,255,255,.8);
  display:flex; align-items:center; gap:12px; font-size:1rem;
  border-bottom:1px solid rgba(255,255,255,.05);
}
.plan-features li:last-child { border-bottom:none; }
.plan-features li i { color:#4ade80; font-size:.9rem; flex-shrink:0; }
.plan-features li strong { color:#fff; font-weight:600; }

/* ===== Select Button ===== */
.plan-select-btn {
  width:100%; padding:14px 24px; border-radius:10px; font-size:1.1rem;
  font-weight:600; border:none; cursor:pointer; transition: all .3s ease;
  text-transform: uppercase; letter-spacing: 1px;
}
.free-plan .plan-select-btn {
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.6);
  border: 1px solid rgba(255,255,255,.2);
}
.free-plan .plan-select-btn:hover:not(:disabled) {
  background: rgba(255,255,255,.15); color: rgba(255,255,255,.8);
}
.premium-btn {
  background: linear-gradient(135deg, #36454F 0%, #3a414c 100%);
  color:#fff; box-shadow: 0 4px 15px rgba(58,65,73,.3);
}
.premium-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #3a414c 0%, #414c54 100%);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(58,65,73,.4);
}
.plan-select-btn:disabled { opacity:.5; cursor:not-allowed; }

/* ===== Footer ===== */
.subscription-modal-footer {
  text-align: center;
  padding: 20px 30px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.subscription-footer-text {
  color: rgba(255, 255, 255, 0.8);
  font-size: 1rem; margin: 0 0 8px 0;
}
.subscription-footer-text i { color:#4ade80; margin-right:8px; }
.subscription-footer-subtext {
  color: rgba(255,255,255,.5); font-size:.9rem; margin:0;
}

/* ===== Spinner ===== */
.spinner-border {
  display:inline-block; width:1rem; height:1rem; vertical-align:text-bottom;
  border: .15em solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spinner-border .75s linear infinite;
}
.spinner-border-sm { width:.8rem; height:.8rem; border-width:.1em; }
@keyframes spinner-border { to { transform: rotate(360deg); } }

/* ===== Toast/Message ===== */
.subscription-message {
  position: fixed; top: 80px; right: 20px;
  padding:16px 24px; border-radius:10px; background: rgba(33,34,44,.95);
  border:1px solid rgba(58,65,73,.3); color:#fff; display:flex; align-items:center; gap:12px;
  box-shadow: 0 10px 25px rgba(0,0,0,.3); z-index:10000;
  transform: translateX(400px);
  transition: transform .3s cubic-bezier(.25,.46,.45,.94);
}
.subscription-message.show { transform: translateX(0); }
.subscription-message-info { border-left: 3px solid #3b82f6; }
.subscription-message-error { border-left: 3px solid #ef4444; }
.subscription-message i { font-size: 1.2rem; }

/* ===== Hover Float (optional) ===== */
@media (hover: hover) {
  .subscription-card { animation: subtle-float 6s ease-in-out infinite; }
  .subscription-card:nth-child(2) { animation-delay: 1s; }
  .subscription-card:nth-child(3) { animation-delay: 2s; }
}
@keyframes subtle-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* ===== Width-based Responsive ===== */
@media (max-width: 1024px) {
  .subscription-plans-container {
    grid-template-columns: 1fr;
    max-width: 500px;
    margin: 0 auto 40px;
  }
  .billing-toggle { width: 100%; }
  .toggle-btn { flex: 1; justify-content: center; }
}
@media (max-width: 768px) {
  .subscription-modal { width: 95%; }
  .subscription-modal-title { font-size: 2rem; }
  .subscription-modal-header, .subscription-modal-body { padding: 20px; }
  .plan-name { font-size: 1.5rem; }
  .price-amount { font-size: 2.5rem; }
  .plan-features li { font-size: .95rem; padding:10px 0; }
  .subscription-card { padding: 25px; }
  .plan-badge { font-size: .75rem; padding: 4px 16px; }
}
@media (max-width: 480px) {
  .subscription-modal-title { font-size: 1.5rem; }
  .plan-name { font-size: 1.3rem; }
  .price-amount { font-size: 2rem; }
  .plan-features li { font-size: .9rem; }
  .subscription-message { right: 10px; left: 10px; top: 60px; }
}

/* ===== Height-aware compaction for laptops ===== */
@media (max-height: 820px) {
  .subscription-modal-header { padding: 24px 24px 0; }
  .subscription-modal-title { font-size: 2.1rem; }
  .subscription-modal-body { padding: 28px 24px; }
}
@media (max-height: 700px) {
  .subscription-modal-title { font-size: 1.8rem; }
  .subscription-modal-body { padding: 22px 18px; }
  .subscription-card { padding: 22px; border-radius: 14px; }
  .plan-features li { padding: 9px 0; }
  .subscription-modal-footer { padding: 16px 20px; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  .subscription-modal,
  .subscription-modal-backdrop,
  .subscription-card {
    animation: none !important;
    transition: opacity .2s ease !important;
  }
}
