/* ======================================================================
   HAISE – Subscriptions Module Styles
   Module-specific styles only - layout handled by /public/css/layout.css
   ====================================================================== */

/* ---- Subscription page specific adjustments ---- */
body.subs-page {
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
  /* Removed display: flex and flex-direction to avoid conflict with .app-shell */
}

/* Scrollbar styling for subscription pages */
body.subs-page .main-content::-webkit-scrollbar {
  width: 10px;
}

body.subs-page .main-content::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

body.subs-page .main-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

body.subs-page .main-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

.subs-card{
background:var(--bg-tertiary);border:1px solid var(--border);border-radius:8px;padding:16px;transition:all 0.2s;}

/* ======================================================================
   SUBSCRIPTION CARDS & PLANS
   ====================================================================== */

.plans-grid {
  display: grid;
  gap: 24px;
  margin-top: 24px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Responsive grid based on number of items */
.plans-grid:has(> :nth-child(2):last-child) {
  grid-template-columns: repeat(2, 1fr);
}

.plans-grid:has(> :nth-child(3):last-child) {
  grid-template-columns: repeat(3, 1fr);
}

.plans-grid:has(> :nth-child(4):last-child) {
  grid-template-columns: repeat(4, 1fr);
}

.plans-grid:has(> :nth-child(6):last-child) {
  grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1200px) {
  .plans-grid:has(> :nth-child(4):last-child) {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 960px) {
  .plans-grid:has(> :nth-child(3):last-child),
  .plans-grid:has(> :nth-child(4):last-child),
  .plans-grid:has(> :nth-child(6):last-child) {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .plans-grid {
    grid-template-columns: 1fr !important;
  }
}

.plan-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  position: relative;
}

.plan-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  border-color: var(--accent);
}

.plan-card h3 {
  margin: 0 0 12px 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
}

.plan-price {
  font-weight: 700;
  font-size: 1.5rem;
  margin-bottom: 16px;
  color: var(--accent);
}

.plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 24px 0;
  flex-grow: 1;
}

.plan-features li {
  padding: 8px 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.plan-features li::before {
  content: "✓ ";
  color: var(--accent);
  font-weight: bold;
  margin-right: 8px;
}

/* Button variants for subscription actions */
.select-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 24px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.select-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(23, 121, 161, 0.3);
}

.select-btn.upgrade {
  background: #2e7d32;
  color: #fff;
}

.select-btn.upgrade:hover {
  background: #1b5e20;
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.4);
}

.select-btn.downgrade {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.select-btn.downgrade:hover {
  background: var(--bg-tertiary);
  border-color: var(--text-secondary);
  transform: translateY(-1px);
}

.select-btn.current {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* ======================================================================
   SUBSCRIPTION ALERTS
   ====================================================================== */

.alert,
.subs-alert {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  display: none;
}

.alert.error,
.subs-alert.error {
  background: #3b1d1d;
  color: #ffd7d7;
  border: 1px solid #6a2b2b;
  display: block;
}

.alert.success,
.subs-alert.success {
  background: #183a2a;
  color: #d7ffea;
  border: 1px solid #2b6a47;
  display: block;
}

.alert.hidden,
.subs-alert.hidden {
  display: none;
}

/* ======================================================================
   USAGE DASHBOARD
   ====================================================================== */

/* Filter bar */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 16px 0 24px;
}

.filter-bar > div {
  min-width: 180px;
}

.filter-bar label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* KPI strip */
.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.kpi {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.kpi .label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.kpi .value {
  font-size: 20px;
  font-weight: 700;
}

@media (max-width: 1200px) {
  .kpis {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .kpis {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}

/* ======================================================================
   TABLES
   ====================================================================== */

.table-wrap {
  overflow: auto;
  max-height: 600px;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.table thead th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

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

/* ======================================================================
   TIER CONFIGURATION PAGE
   ====================================================================== */

.tiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 16px;
}

@media (max-width: 1400px) {
  .tiers-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1024px) {
  .tiers-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

@media (max-width: 768px) {
  .tiers-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

.tier-card-wrapper {
  height: 100%;
}

#tiersList .card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  word-wrap: break-word;
  min-width: 0;
}

#tiersList .card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#tiersList .card strong {
  font-size: 18px;
  color: var(--text-primary);
  display: block;
  margin-bottom: 4px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

#tiersList .card .muted {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  word-wrap: break-word;
}

@media (max-width: 1400px) {
  #tiersList .card strong {
    font-size: 16px;
  }

  #tiersList .card {
    padding: 14px;
  }
}

@media (max-width: 768px) {
  #tiersList .card strong {
    font-size: 15px;
    line-height: 1.3;
  }

  #tiersList .card {
    padding: 12px;
  }
}

/* ======================================================================
   ADMIN DASHBOARD
   ====================================================================== */

.sync-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  padding: 24px;
  margin-top: 32px;
}

.sync-card h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-weight: 600;
}

.sync-card .row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 20px 0;
}

.sync-card .row > div {
  flex: 1;
  min-width: 150px;
}

.sync-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.sync-card input {
  width: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.sync-card .presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.preset-btn {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.sync-card .status {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  min-height: 20px;
}

.sync-card .links {
  margin-top: 16px;
}

.subs-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.subs-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Model card for admin dashboard */
.model-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: all 0.3s ease;
}

.model-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  border-color: var(--accent);
}

.model-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.model-provider {
  color: var(--text-secondary);
}

.model-costs {
  margin: 16px 0;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.model-costs > div {
  margin: 6px 0;
  font-size: 14px;
  color: var(--text-secondary);
}

.cost-in,
.cost-out {
  color: var(--text-primary);
  font-weight: 600;
}

.markup-line {
  margin-top: 12px;
  font-size: 14px;
}

.markup-line .markup {
  color: var(--accent);
  font-weight: 700;
}
