/* IST PVSolar Simulator V8.1.0 — Stylesheet */
:root {
  --gray: #4a4a4a;
  --skyblue: #0078c8;
  --skyblue-light: #e8f4fd;
  --white: #ffffff;
  --black: #000000;
  --border: #333;
  --accent: #e67e00;
  --green: #1a8a1a;
  --red: #c0392b;
  --yellow: #f1c40f;
  --bg-card: #f9fafb;
  --result: #e8f7e8;
  --title-bg: #3c3c3c;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Arial, sans-serif; font-size: 13px; color: var(--black); background: #e8e8e8; }

/* TITLE BAR */
.titlebar {
  background: var(--title-bg);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  height: 40px;
}
.titlebar-left { display: flex; align-items: center; gap: 8px; }
.app-icon { font-size: 22px; color: #FFD700; }
.app-title { font-size: 16px; font-weight: 700; letter-spacing: 0.5px; }
.app-version { font-size: 11px; color: #aaa; background: #222; padding: 2px 6px; border-radius: 3px; }
.titlebar-right { display: flex; gap: 6px; }
.btn-icon {
  background: transparent; border: 1px solid #666; color: white;
  padding: 3px 8px; border-radius: 3px; cursor: pointer; font-size: 14px;
  transition: background 0.2s;
}
.btn-icon:hover { background: #555; }

/* MENU BAR */
.menubar {
  background: var(--skyblue);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  height: 32px;
}
.menu-group { display: flex; gap: 2px; }
.menu-btn {
  background: transparent; border: none; color: white;
  padding: 4px 12px; cursor: pointer; font-size: 13px; border-radius: 2px;
  transition: background 0.2s;
}
.menu-btn:hover { background: rgba(255,255,255,0.2); }
.menu-status { color: rgba(255,255,255,0.85); font-size: 12px; font-style: italic; }

/* TAB CONTAINER */
.tab-container { background: white; margin: 0; }
.tabs {
  background: var(--skyblue-light);
  border-bottom: 2px solid var(--skyblue);
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}
.tab {
  background: transparent; border: none; border-right: 1px solid #ccc;
  color: var(--skyblue); padding: 8px 14px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; transition: all 0.2s;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tab:hover { background: rgba(0,120,200,0.1); }
.tab.active { background: white; color: var(--skyblue); border-bottom: 2px solid white; border-top: 2px solid var(--skyblue); }

.tab-content { display: none; padding: 12px; min-height: calc(100vh - 150px); }
.tab-content.active { display: block; }
.tab-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; border-bottom: 2px solid var(--skyblue); padding-bottom: 6px; }
.tab-header h2 { font-size: 15px; color: var(--skyblue); font-weight: 700; }
.help-link { color: var(--skyblue); font-size: 12px; text-decoration: none; background: var(--skyblue-light); padding: 3px 8px; border-radius: 3px; border: 1px solid var(--skyblue); }
.help-link:hover { background: var(--skyblue); color: white; }

/* CARDS */
.card { background: white; border: 1px solid #ddd; border-radius: 4px; padding: 12px; margin-bottom: 8px; }
.card h3 { font-size: 13px; font-weight: 700; color: var(--skyblue); border-bottom: 1px solid #e0e0e0; padding-bottom: 6px; margin-bottom: 8px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mt10 { margin-top: 10px; }

/* FORMS */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; align-items: left; }
.form-grid label { font-weight: 600; font-size: 12px; color: #333; text-align: left; }
.form-grid input, .form-grid select, .form-grid textarea {
  border: 1px solid #bbb; border-radius: 3px; padding: 4px 6px;
  font-size: 12px; width: 100%; background: white;
}
.form-grid input:focus, .form-grid select:focus { outline: none; border-color: var(--skyblue); box-shadow: 0 0 0 2px rgba(0,120,200,0.15); }
.result-field { background: var(--result) !important; font-weight: 700; color: #0a5c0a; }

/* BUTTONS */
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn-primary {
  background: var(--skyblue); color: white; border: none;
  padding: 6px 14px; border-radius: 3px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  transition: background 0.2s;
}
.btn-primary:hover { background: #005fa3; }
.btn-secondary {
  background: #6c757d; color: white; border: none;
  padding: 6px 14px; border-radius: 3px; cursor: pointer; font-size: 12.5px;
  transition: background 0.2s;
}
.btn-secondary:hover { background: #545b62; }
.btn-large { padding: 8px 20px; font-size: 14px; }
.btn-danger { background: var(--red); color: white; border: none; padding: 3px 8px; border-radius: 3px; cursor: pointer; font-size: 11px; }

/* TABLES */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { background: var(--skyblue); color: white; padding: 6px 8px; text-align: center; font-weight: 700; border: 1px solid #0060a0; width: fit-content;}
.data-table td { padding: 5px 8px; border: 1px solid #ddd; text-align: center;width: fit-content; }
.data-table tbody tr:nth-child(even) { background: #f5f9ff; }
.data-table tbody tr:hover { background: #e8f4fd; }
.data-table input { border: 1px solid #ccc; padding: 2px 4px; font-size: 11px; width: 100%; min-width: 60px; }
.row-payback { background: #c8f5c8 !important; font-weight: 700; }

/* PARAM BOX / FORMULA BOX */
.param-box { background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 3px; padding: 10px; font-size: 12px; line-height: 1.7; }
.formula-box {  background: #fff8e1; border-left: 3px solid var(--accent); padding: 8px 10px; font-family: 'Courier New', monospace; font-size: 11.5px; line-height: 1.6; }
.link{visibility: hidden; height: 0px;max-height:0px; overflow: hidden;}
/* STATUS */
.status-msg { padding: 6px 10px; border-radius: 3px; font-size: 12px; margin-top: 6px; }
.status-ok { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status-err { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.status-info { background: var(--skyblue-light); color: #0c5460; border: 1px solid #bee5eb; }

/* FOOTER */
.footer {
  background: var(--title-bg); color: #ccc; font-size: 11px;
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 14px; position: sticky; bottom: 0; z-index: 100;
}

/* MODALS */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.55); z-index: 1000; display: flex; align-items: flex-start; justify-content: center; padding: 30px 10px; overflow-y: auto; }
.modal-content { background: white; border-radius: 6px; width: 600px; max-width: 100%; box-shadow: 0 10px 40px rgba(0,0,0,0.4); }
.modal-wide { width: 90%; max-width: 1100px; }
.modal-report { width: 95%; max-width: 1200px; max-height: 95vh; display: flex; flex-direction: column; }
.modal-header { background: var(--skyblue); color: white; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; border-radius: 6px 6px 0 0; }
.modal-header h2 { font-size: 14px; }
.close-btn { background: transparent; border: 1px solid rgba(255,255,255,0.5); color: white; padding: 2px 8px; border-radius: 3px; cursor: pointer; font-size: 14px; }
.modal-body { padding: 14px; overflow-y: auto; max-height: 80vh; }

/* UNITS (Tab 5) */
.unit-card { border: 1px solid #aad4f5; background: #f0f8ff; border-radius: 4px; padding: 10px; margin-bottom: 10px; }
.unit-card h4 { color: var(--skyblue); font-size: 12.5px; margin-bottom: 8px; display: flex; justify-content: space-between; }
.unit-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.unit-result { background: var(--result); border: 1px solid #9dd; border-radius: 3px; padding: 4px 6px; font-size: 11.5px; font-weight: 700; color: #0a5c0a; text-align: center; }

/* REPORT STYLES (A4) */
.report-page {
  background: white; width: 210mm; min-height: 297mm; margin: 0 auto 20px;
  padding: 15mm 20mm 20mm; box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  font-family: Arial, sans-serif; font-size: 11pt; color: black;
  position: relative; page-break-after: always;
}
.report-header { border-bottom: 2px solid black; padding-bottom: 8px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: flex-start; }
.report-header-left .logo-text { font-size: 16pt; font-weight: bold; color: #00000; }
.report-header-left .sub-text { font-size: 9pt; color: #555; }
.report-header-right { text-align: right; font-size: 9pt; }
.report-footer { border-top: 1px solid black; padding-top: 5px; margin-top: 20px; font-size: 8pt; color: #555; display: flex; justify-content: space-between; }
.report-title { text-align: center; font-size: 20pt; font-weight: bold; color: #0055aa; margin: 30px 0 8px; }
.report-subtitle { text-align: center; font-size: 12pt; margin-bottom: 20px; }
.report-info-box { border: 1px solid #333; padding: 12px 16px; margin: 16px 0; background: #f9f9f9; }
.report-info-box table { width: 100%; border-collapse: collapse; }
.report-info-box td { padding: 3px 6px; font-size: 10pt; vertical-align: top; }
.report-info-box td:first-child { font-weight: bold; width: 40%; }
.report-h2 { font-size: 12pt; font-weight: bold; color: #0055aa; border-bottom: 1px solid #0055aa; padding-bottom: 3px; margin: 16px 0 8px; }
.report-h3 { font-size: 10.5pt; font-weight: bold; margin: 12px 0 6px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 9.5pt; margin: 8px 0; }
.report-table th { background: #0055aa; color: white; padding: 4px 6px; text-align: center; border: 1px solid #0033aa; font-weight: bold; }
.report-table td { padding: 3px 6px; border: 1px solid #bbb; text-align: center; }
.report-table tbody tr:nth-child(even) { background: #f0f5ff; }
.sig-box { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 30px; }
.sig-item { border: 1px solid #999; padding: 10px; min-height: 80px; }
.sig-item .sig-label { font-weight: bold; font-size: 9pt; margin-bottom: 4px; }
.sig-item .sig-line { border-top: 1px solid #555; margin-top: 30px; font-size: 9pt; color: #555; }
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 10px 0; }
.kpi-item { border: 1px solid #ddd; padding: 8px; text-align: center; background: #f8faff; }
.kpi-item .kpi-val { font-size: 14pt; font-weight: bold; color: #0055aa; }
.kpi-item .kpi-label { font-size: 8pt; color: #555; }

/* CHART CONTAINERS */
#poaChartContainer, #eacChartContainer, #cdfChartSim, #cdfChartContainer,
#gridChartContainer, #prChartContainer, #lifeChartContainer, #sankeyContainer { min-height: 200px; }

/* PRINT — only report area, A4 pages */
@media print {
  @page { size: A4; margin: 0; }

  /* Hide everything except the report modal body */
  body > *,
  .titlebar, .menubar, .tab-container, .footer,
  button, .btn-row, .help-link,
  .modal-header { display: none !important; }

  /* Show the report modal as a flat document */
  #reportModal {
    display: block !important;
    position: static !important;
    background: white !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }
  #reportModal .modal-content {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    overflow: visible !important;
  }
  #reportModal .modal-header { display: none !important; }
  #reportModal .modal-body {
    display: block !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 !important;
  }
  .report-page {
    box-shadow: none !important;
    border: none !important;
    margin: 0 auto !important;
    width: 210mm !important;
    min-height: 297mm !important;
    page-break-after: always !important;
    padding: 15mm 20mm 20mm !important;
  }
  .report-page:last-child { page-break-after: avoid !important; }
  body { background: white !important; }
}

@media (max-width: 768px) {
  .two-col { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label { text-align: left; }
  .unit-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* AI ASSISTANT */
.ai-quick-btn {
  background: #f0f4ff; border: 1px solid #aac4ee; color: #0055aa;
  padding: 5px 11px; border-radius: 14px; cursor: pointer; font-size: 12px;
  font-weight: 600; transition: all 0.15s; white-space: nowrap;
}
.ai-quick-btn:hover { background: #0055aa; color: white; border-color: #0055aa; }
.ai-msg-user {
  background: #0055aa; color: white; border-radius: 12px 12px 2px 12px;
  padding: 8px 12px; margin: 6px 0 6px 30px; font-size: 12.5px; line-height: 1.6;
}
.ai-msg-ai {
  background: white; border: 1px solid #dde; border-radius: 2px 12px 12px 12px;
  padding: 10px 13px; margin: 6px 30px 6px 0; font-size: 12.5px; line-height: 1.75;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.ai-msg-ai strong { color: #0055aa; }
.ai-msg-ai .ai-section { margin: 6px 0; padding-left: 12px; border-left: 2px solid #aad4f5; }
.ai-thinking {
  display: flex; align-items: center; gap: 8px; color: #888; font-size: 12px;
  padding: 8px 12px; background: #f8f8ff; border-radius: 8px; margin: 4px 30px 4px 0;
}
.ai-dot { width:7px; height:7px; border-radius:50%; background:#0055aa; animation: aiPulse 1.2s infinite; display:inline-block; }
.ai-dot:nth-child(2) { animation-delay:0.3s; }
.ai-dot:nth-child(3) { animation-delay:0.6s; }
@keyframes aiPulse { 0%,80%,100% { opacity:0.2; transform:scale(0.8); } 40% { opacity:1; transform:scale(1); } }

/* ============================================================
   NUMERIC STEPPER — ± buttons on every number input
   ============================================================ */
.num-stepper {
  display: inline-flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid #bbb;
  border-radius: 3px;
  overflow: hidden;
  background: white;
  transition: box-shadow 0.15s;
}
.num-stepper:focus-within {
  border-color: var(--skyblue, #0078c8);
  box-shadow: 0 0 0 2px rgba(0,120,200,0.15);
}
.num-stepper input[type="number"] {
  flex: 1;
  min-width: 0;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 3px 4px !important;
  font-size: 12px !important;
  text-align: center;
  background: transparent;
  /* hide native spin arrows */
  -moz-appearance: textfield;
  appearance: textfield;
}
.num-stepper input[type="number"]::-webkit-inner-spin-button,
.num-stepper input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.num-stepper .ns-btn {
  flex: 0 0 22px;
  width: 22px;
  border: none;
  background: #f0f4f8;
  color: #2a5f8a;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  transition: background 0.1s, color 0.1s;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.num-stepper .ns-btn:hover {
  background: #0078c8;
  color: white;
}
.num-stepper .ns-btn:active {
  background: #005a99;
  color: white;
}
.num-stepper .ns-btn.ns-minus {
  border-right: 1px solid #ddd;
  order: -1;
}
.num-stepper .ns-btn.ns-plus {
  border-left: 1px solid #ddd;
}
/* readonly inputs — no steppers, keep result-field look */
.num-stepper.ns-readonly {
  background: var(--result, #e8f5e9);
  pointer-events: none;
}
.num-stepper.ns-readonly .ns-btn { display: none; }
.num-stepper.ns-readonly input { font-weight: 700; color: #0a5c0a; background: transparent; }

/* Inside data-table cells — compact */
.data-table .num-stepper { border-color: #ccc; }
.data-table .num-stepper .ns-btn { flex: 0 0 18px; width: 18px; font-size: 13px; }
