/* ═══════════════════════════════════════════════════════
   PRAYOSHA INVESTMENT CALCULATORS — STYLESHEET v2.0
   Fully responsive: Desktop → Tablet → Mobile
   Brand: #3b3968 (indigo) | #e63325 (red)
   ═══════════════════════════════════════════════════════ */

:root {
  --pi-primary: #3b3968;
  --pi-red:     #e63325;
  --pi-light:   #f4f4f8;
  --pi-white:   #ffffff;
  --pi-gray:    #6b7280;
  --pi-border:  #e2e4ef;
  --pi-shadow:  0 2px 16px rgba(59,57,104,0.10);
  --pi-radius:  12px;
}

/* ══ GLOBAL RESET (scoped) ══ */
.pinv-wrap *, .pinv-wrap *::before, .pinv-wrap *::after {
  box-sizing: border-box; margin: 0; padding: 0;
}
.pinv-wrap {
  font-family: 'Segoe UI','Helvetica Neue',Arial,sans-serif;
  color: #1a1a2e;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 56px;
  width: 100%;
}

/* ══════════════════════════════════════════════════════
   TABS — hard-isolated from WordPress theme interference
   ══════════════════════════════════════════════════════ */
.pinv-tabs {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: stretch;
  gap: 6px;
  margin: 28px auto 32px;
  background: #e8e8f2;
  border-radius: 60px;
  padding: 5px 6px;
  width: fit-content;
  max-width: calc(100% - 32px);
  box-shadow: inset 0 1px 4px rgba(59,57,104,0.10);
}

/* Full reset on button — kills every WordPress theme override */
.pinv-wrap .pinv-tab {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border-radius: 60px;
  padding: 11px 30px;
  font-family: 'Segoe UI','Helvetica Neue',Arial,sans-serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--pi-gray);
  cursor: pointer;
  white-space: nowrap;
  transition: background .22s, color .22s, box-shadow .22s;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}
.pinv-wrap .pinv-tab:hover:not(.active) {
  background: rgba(59,57,104,0.09);
  color: var(--pi-primary);
}
.pinv-wrap .pinv-tab.active {
  background: var(--pi-primary) !important;
  color: #fff !important;
  box-shadow: 0 3px 14px rgba(59,57,104,0.36);
}

/* ── Tab icons (emoji, shown inline) ── */
.pinv-tab-icon { font-size: 15px; line-height: 1; }

/* ══ MOBILE TABS: stack full-width ══ */
@media (max-width: 560px) {
  .pinv-tabs {
    flex-direction: column;
    border-radius: 18px;
    width: calc(100% - 0px);
    max-width: 100%;
    gap: 4px;
    padding: 6px;
    margin-left: 0; margin-right: 0;
  }
  .pinv-wrap .pinv-tab {
    width: 100%;
    text-align: center;
    justify-content: center;
    border-radius: 12px;
    padding: 15px 20px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .2px;
  }
  .pinv-wrap .pinv-tab.active {
    border-radius: 12px !important;
  }
}

/* ══ TAB CONTENT ══ */
.pinv-tab-content { display: none; }
.pinv-tab-content.active { display: block; }

/* ══════════════════════════════════════════════════════
   CARD GRID — hub page
   ══════════════════════════════════════════════════════ */
.pinv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
@media (max-width: 960px) { .pinv-grid { grid-template-columns: repeat(2,1fr); gap: 14px; } }
@media (max-width: 560px) { .pinv-grid { grid-template-columns: 1fr; gap: 12px; } }

/* ── Card ── */
.pinv-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--pi-white);
  border: 1px solid var(--pi-border);
  border-radius: var(--pi-radius);
  padding: 20px 18px;
  text-decoration: none !important;
  color: inherit !important;
  box-shadow: var(--pi-shadow);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  cursor: pointer;
  min-height: 90px;
}
.pinv-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(59,57,104,0.16);
  border-color: var(--pi-primary);
}
.pinv-card-body { flex: 1; min-width: 0; }
.pinv-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--pi-primary);
  margin-bottom: 5px;
  line-height: 1.35;
}
.pinv-card-desc {
  font-size: 12px;
  color: var(--pi-gray);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pinv-card-icon {
  flex-shrink: 0;
  width: 48px; height: 48px;
  background: var(--pi-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 14px;
}
.pinv-card-icon svg { width: 26px; height: 26px; }

@media (max-width: 560px) {
  .pinv-card { padding: 16px 14px; min-height: 80px; }
  .pinv-card-title { font-size: 13px; }
  .pinv-card-icon { width: 40px; height: 40px; margin-left: 10px; }
  .pinv-card-icon svg { width: 22px; height: 22px; }
}

/* ══════════════════════════════════════════════════════
   INDIVIDUAL CALCULATOR PAGE
   ══════════════════════════════════════════════════════ */
.pinv-calc-page { padding-top: 20px; }

/* Header */
.pinv-calc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.pinv-calc-title {
  font-size: clamp(18px, 5vw, 28px);
  font-weight: 800;
  color: var(--pi-primary);
  letter-spacing: .4px;
  line-height: 1.2;
}
.pinv-explore {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--pi-gray);
  flex-wrap: wrap;
}
.pinv-explore select {
  border: 1.5px solid var(--pi-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--pi-primary);
  background: var(--pi-white);
  min-width: 180px;
  max-width: 100%;
  cursor: pointer;
  outline: none;
}
.pinv-explore select:focus { border-color: var(--pi-primary); }

@media (max-width: 560px) {
  .pinv-calc-header { flex-direction: column; align-items: flex-start; }
  .pinv-explore { width: 100%; }
  .pinv-explore select { flex: 1; min-width: 0; width: 100%; }
}

/* ── 2-col body ── */
.pinv-calc-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 800px) {
  .pinv-calc-body { grid-template-columns: 1fr; gap: 16px; }
}

/* ── Left panel (inputs) ── */
.pinv-calc-left {
  background: var(--pi-white);
  border: 1px solid var(--pi-border);
  border-radius: var(--pi-radius);
  padding: 24px 20px;
  box-shadow: var(--pi-shadow);
}
.pinv-input-group { margin-bottom: 20px; }
.pinv-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
}
.pinv-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pinv-input-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--pi-primary);
  height: 6px;
  cursor: pointer;
  /* override WP themes that shrink range inputs */
  -webkit-appearance: auto;
  appearance: auto;
}
.pinv-input-row input[type="number"],
.pinv-input-row input[type="text"] {
  width: 100px;
  flex-shrink: 0;
  border: 1.5px solid var(--pi-border);
  border-radius: 8px;
  padding: 8px 8px;
  font-size: 13px;
  font-weight: 700;
  text-align: right;
  color: var(--pi-primary);
  outline: none;
  background: #fafafa;
  transition: border-color .2s;
  /* hide spinner arrows on mobile — saves space */
  -moz-appearance: textfield;
}
.pinv-input-row input[type="number"]::-webkit-inner-spin-button,
.pinv-input-row input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.pinv-input-row input[type="number"]:focus,
.pinv-input-row input[type="text"]:focus { border-color: var(--pi-primary); background: #fff; }

@media (max-width: 400px) {
  .pinv-input-row input[type="number"],
  .pinv-input-row input[type="text"] { width: 86px; font-size: 12px; padding: 7px 6px; }
}

.pinv-divider { border: none; border-top: 1.5px solid var(--pi-border); margin: 18px 0; }

/* Result rows */
.pinv-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f8;
  font-size: 13.5px;
  gap: 8px;
}
.pinv-result-row:last-child { border-bottom: none; }
.pinv-result-row span:first-child { color: var(--pi-gray); flex: 1; }
.pinv-result-row span:last-child  { font-weight: 700; color: var(--pi-primary); font-size: 15px; text-align: right; white-space: nowrap; }

/* ── Right panel (charts) ── */
.pinv-calc-right { display: flex; flex-direction: column; gap: 18px; }
.pinv-chart-box {
  background: var(--pi-white);
  border: 1px solid var(--pi-border);
  border-radius: var(--pi-radius);
  padding: 18px 16px;
  box-shadow: var(--pi-shadow);
  /* prevent chart overflow on mobile */
  min-width: 0;
  overflow: hidden;
}
.pinv-chart-title {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--pi-primary);
  margin-bottom: 12px;
  letter-spacing: .2px;
}
/* Charts must scale down on small screens */
.pinv-chart-box canvas {
  max-height: 240px;
  width: 100% !important;
  height: auto !important;
}

/* ── Action buttons ── */
.pinv-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}
.pinv-print-btn {
  background: var(--pi-red);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .15s;
  white-space: nowrap;
}
.pinv-print-btn:hover { background: #c9281d; transform: translateY(-1px); }
.pinv-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--pi-light);
  color: var(--pi-primary);
  border-radius: 8px;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background .2s;
  white-space: nowrap;
}
.pinv-back-btn:hover { background: #ddddf0; }

@media (max-width: 560px) {
  .pinv-actions { gap: 10px; }
  .pinv-print-btn, .pinv-back-btn { flex: 1; text-align: center; justify-content: center; padding: 13px 14px; font-size: 13.5px; }
}

/* ══════════════════════════════════════════════════════
   PERFORMER TABLES — fully responsive
   ══════════════════════════════════════════════════════ */
.pinv-perf-info {
  background: var(--pi-white);
  border: 1px solid var(--pi-border);
  border-radius: var(--pi-radius);
  padding: 26px 22px;
  box-shadow: var(--pi-shadow);
  width: 100%;
  max-width: 100%;
}
.pinv-perf-info h3 {
  color: var(--pi-primary);
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 8px;
}
.pinv-perf-info .pinv-perf-desc {
  color: var(--pi-gray);
  line-height: 1.65;
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* Live badge */
.pinv-live-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 700;
  margin-bottom: 14px;
  letter-spacing: .3px;
}
.pinv-live-badge::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #10b981;
  animation: pinv-pulse 1.5s infinite;
}
@keyframes pinv-pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .5; transform: scale(1.3); }
}

/* Scrollable wrapper for tables on mobile */
.pinv-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--pi-border);
}
.pinv-perf-table {
  width: 100%;
  min-width: 420px; /* prevents squish below this */
  border-collapse: collapse;
  font-size: 13.5px;
}
.pinv-perf-table th {
  background: var(--pi-primary);
  color: #fff;
  padding: 11px 14px;
  text-align: left;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .3px;
}
.pinv-perf-table th:first-child { border-radius: 0; }
.pinv-perf-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--pi-border);
  color: #1a1a2e;
  white-space: nowrap;
}
.pinv-perf-table td:first-child { color: var(--pi-primary); font-weight: 600; }
.pinv-perf-table tr:last-child td { border-bottom: none; }
.pinv-perf-table tr:nth-child(even) td { background: var(--pi-light); }
.pinv-perf-table td.perf-up   { color: #059669; font-weight: 700; }
.pinv-perf-table td.perf-down { color: var(--pi-red); font-weight: 700; }

/* Fetching/loading state */
.pinv-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 0;
  color: var(--pi-gray);
  font-size: 13.5px;
}
.pinv-spinner {
  width: 20px; height: 20px;
  border: 3px solid var(--pi-border);
  border-top-color: var(--pi-primary);
  border-radius: 50%;
  animation: pinv-spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes pinv-spin { to { transform: rotate(360deg); } }

/* Data fetch error */
.pinv-fetch-note {
  font-size: 12px;
  color: var(--pi-gray);
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--pi-light);
  border-radius: 8px;
  border-left: 3px solid var(--pi-primary);
}

/* ══════════════════════════════════════════════════════
   A4 PRINT STYLES
   ══════════════════════════════════════════════════════ */
@media print {
  body > *:not(.pinv-print-area) { display: none !important; }
  .pinv-print-area {
    display: block !important;
    position: fixed;
    top: 0; left: 0;
    width: 210mm; min-height: 297mm;
    padding: 18mm 18mm 14mm;
    background: #fff;
    font-family: 'Segoe UI', sans-serif;
    z-index: 99999;
  }
  .pinv-print-area * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.pinv-print-area { display: none; }
