

/* =========================================================
   0. Page container
   ========================================================= */
.container {
  max-width: 980px;
  margin: 18px auto;
  padding: 0 14px;
}

/* =========================================================
   1. Base Layout & Typography
   ========================================================= */
body, input, select, button, label, h1, h2, h3, h4, h5, h6, div, span {
  font-family: Arial, Helvetica, "Noto Sans Malayalam", "Kartika", sans-serif;
  font-size: 14px;
  color: #222;
}

h1 {
  color: #5508f0;
  text-align: center;
  font-family: 'Noto Sans Malayalam', 'Noto Sans', 'Arial', sans-serif;
  font-size: 20px;
  font-weight: bold;
  margin: 10px 0 14px;
}

h2 {
  color: blue;
  font-size: 16px;
  text-align: left;
  font-family: 'Noto Sans Malayalam', 'Noto Sans', 'Arial', sans-serif;
  font-weight: bold;
  margin: 0.5rem 0;
  display: inline-block;
  border-bottom: 3px solid blue;
  padding-bottom: 2px;
}

h3 {
  color: blue;
  font-size: 16px;
  text-align: left;
  font-family: 'Noto Sans Malayalam', 'Noto Sans', 'Arial', sans-serif;
  font-weight: bold;
  margin: 0.25rem 0;
}

.no-underline { border-bottom: none !important; }
hr { margin: 0.1rem 0; }

@media (min-width: 600px) { h1 { font-size: 2rem; } }

/* =========================================================
   2. Form Elements
   ========================================================= */
/* only style form buttons, not action buttons */
form button,
input[type="number"],
select {
  font-size: 16px;
  padding: 8px;
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
  margin-bottom: 10px;
}

input, select, textarea {
  line-height: 1.4;
  padding: 8px; /* Prevents mobile zoom on focus */
}

button { cursor: pointer; }

@media (min-width: 768px) {
  select, input[type="number"], button { max-width: 500px; }
}
@media (max-width: 767px) {
  select, input[type="number"], button { font-size: 20px; }
}

/* Hide buttons and controls when printing */
@media print { .no-print { display: none !important; } }

input, select, button, label {
  max-width: 100% !important;
  box-sizing: border-box;
}

/* =========================================================
   3. Grid Placement Helpers
   ========================================================= */
.full-row { grid-column: span 2; }
.left-col { grid-column: 1; }
.right-col { grid-column: 2; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* fixed 2 columns */
  gap: 12px;
  max-width: 900px;
  margin: auto;
}

.form-group.full-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.form-group.full-row label {
  flex: none;
  width: 220px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

.form-group.full-row input,
.form-group.full-row select { flex: none; }

.form-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: #f9f9f9;
}

.form-group label {
  flex: 1 1 200px;
  min-width: 120px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

.form-group input,
.form-group select {
  flex: 1 1 100px;
  max-width: 100%;
  box-sizing: border-box;
}

/* =========================================================
   4. Results Output Box
   ========================================================= */
.result {
  background: #e3f2fd;
  padding: 1rem;
  margin-top: 1rem;
  word-wrap: break-word;
  page-break-inside: avoid;
}
.result h3 { margin: 1rem 0; }

/* =========================================================
   5. Timestamp & Update Info
   ========================================================= */
.timestamp {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 1rem;
}

/* =========================================================
   6. Debug Panel
   ========================================================= */
.debug {
  background: #fff8dc;
  color: #333;
  font-family: monospace;
  white-space: pre-wrap;
  border: 1px dashed #aaa;
  padding: 1rem;
  margin-top: 1rem;
}

.hidden {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

/* =========================================================
   7. Extra UI Additions (Action Buttons, Page Header, Info Bar, Announcement)
   ========================================================= */
.btn-row {
  display: flex;
  gap: 10px;
  margin: 15px 0;
  flex-wrap: nowrap;
  justify-content: flex-start;
}

.btn-row .action-btn {
  flex: 0 0 auto;
  width: auto !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.1s ease;
}
.btn-row .action-btn:hover { transform: translateY(-2px); }

.btn-blue { background-color: #0077cc; color: #fff; }
.btn-blue:hover { background-color: #005fa3; }

.btn-green { background-color: #28a745; color: #fff; }
.btn-green:hover { background-color: #1e7e34; }

/* Purple Button */
.btn-purple {
  background-color: #9b59b6; /* soft purple */
  color: #fff;
}
.btn-purple:hover {
  background-color: #7d3c98; /* darker on hover */
}

.page-header {
  background: #e8eaf6;
  border: 2px solid #3f51b5;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
}
.page-header h1 {
  margin: 0;
  color: #3f51b5;
  font-size: 1.6rem;
  font-weight: bold;
}

.info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #555;
  margin: 5px 0 8px;
  gap: 10px;
  flex-wrap: wrap;
}
.info-bar div { white-space: nowrap; }

.announcement {
  position: relative;
  background-color: #fff3cd;
  border: 1px solid #ffeeba;
  border-radius: 6px;
  padding: 50px 40px 12px 14px; /* extra right padding for the close button */
  margin: 15px 0;
  font-size: 0.95rem;
  color: #856404;
  font-weight: 500;
}
.announcement-text { display: block; }

.announcement-close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: none;
  border: none;
  color: #856404;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease;
}
.announcement-close:hover { color: #d9534f; }

/* =========================================================
   8. PDF Download Button
   ========================================================= */
#downloadFullPDF {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 0.75rem;
  font-size: 1rem;
  width: 100%;
  margin-top: 2rem;
}
#downloadFullPDF { margin-top: 4px !important; }

/* PDF page-break helpers */
.pdf-page-break {
  page-break-before: always !important;
  break-before: page !important;
  display: block !important;
  margin: 0;
  padding: 0;
  border: none;
  height: 50px;
  background: none;
}
.avoid-page-break {
  page-break-inside: avoid !important;
  break-inside: avoid !important;
  -webkit-column-break-inside: avoid !important;
  -moz-column-break-inside: avoid !important;
  display: block !important;
  margin-bottom: 0 !important;
  padding-bottom: 1 !important;
  overflow: visible !important;
}

/* =========================================================
   9. PDF & Print Adjustments
   ========================================================= */
@media screen and (max-width: 768px) {
  #pdfContent {
    transform: scale(0.94);
    transform-origin: top left;
  }
}
@media print {
  #pdfContent {
    width: 100% !important;
    font-size: 12px !important;
    transform: none !important;
  }
  #billForm,
  #downloadFullPDF,
  .timestamp,
  #debugPanel { display: none !important; }
  .result { display: block !important; }
  body {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* =========================================================
   10. Global Width & Overflow Fix
   ========================================================= */
html, body, #pdfContent {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
#pdfNameInputs {
  margin: 2px 0 !important;
  padding: 0 !important;
}

/* =========================================================
   11. Toggle Switch
   ========================================================= */
.switch {
  position: relative;
  display: inline-block;
  width: 30px;
  height: 18px;
}
.slider {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  border-radius: 16px;
  transition: .4s;
}
.slider:before {
  position: absolute;
  content: "";
  height: 12px; width: 12px;
  left: 2px; bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: .4s;
}
.switch input:checked + .slider { background-color: #4CAF50; }
.switch input:checked + .slider:before { transform: translateX(14px); }

/* =========================================================
   12. Ensure Solar Generation Group Shows
   ========================================================= */
#solarGenerationGroup {
  display: block !important;
  visibility: visible !important;
}

/* =========================================================
   13. Small-screen Label Tweak
   ========================================================= */
@media screen and (max-width: 480px) {
  #wheelingCategory + label,
  .form-group label { font-size: 12px !important; }
}

@media (max-width: 600px) {
  .btn-row {
    display: block !important;     /* kill flex */
    margin: 10px 0 !important;
  }

  .btn-row .action-btn {
    display: block !important;     /* full block */
    width: 95% !important;         /* nearly full width */
    max-width: none !important;    /* remove 400px cap */
    margin: 10px auto !important;  /* center and separate */
    white-space: normal !important;/* allow text wrapping */
    flex: none !important;         /* kill flex rules */
  }
}


#pdfNameInputs{
  display:flex !important;
  flex-direction:row !important;
  flex-wrap:nowrap !important;
  align-items:flex-end !important;
  justify-content:flex-start !important;
  gap:1rem !important;

  width:100% !important;
  max-width:900px !important;
  margin:0 auto !important;

  visibility:visible !important;
  opacity:1 !important;
}

#pdfNameInputs .pdf-field{
  display:flex !important;
  flex-direction:column !important;
  flex:0 0 auto !important;
}

#pdfNameInputs label{
  margin-bottom:0.2rem;
}

.pdf-input{
  margin:0;
  box-sizing:border-box;
  font-size:16px;
}

#consumerName{
  width:110px;
}

#billMonth{
  width:100px;
}

.pdf-year{
  width:80px;
}

#pdfHelperText{
  display:block !important;

  font-size:0.7rem;
  color:#555;
  margin-top:2px;
  text-align:left;

  visibility:visible !important;
  opacity:1 !important;
}



/* =========================
   AI FLOATING CONTAINER
========================= */

#aiContainer {

  position: fixed;

  right: 16px;
  bottom: 90px;

  z-index: 999999;

  display: flex;
  flex-direction: column;

  align-items: center;

  gap: 8px;

  touch-action: none;

}

/* =========================
   LANGUAGE SELECTOR
========================= */

#voiceLang {

  width: 55px;

  height: 32px;

  padding: 2px 6px;

  border-radius: 8px;

  border: 1px solid #ccc;

  background: white;

  font-size: 12px;

  box-shadow:
    0 2px 8px rgba(0,0,0,0.2);

}


/* =========================
   DRAG HANDLE
========================= */

#aiDragHandle {

  width: 50px;

  height: 28px;

  border-radius: 14px;

  background: rgba(0,0,0,0.18);

  color: #444;

  display: flex;

  align-items: center;
  justify-content: center;

  font-size: 18px;

  cursor: move;

  user-select: none;

  touch-action: none;

}


/* =========================
   AI MIC BUTTON
========================= */

.ai-mic-btn {

  width: 60px;
  height: 60px;

  border: none;

  border-radius: 50%;

  background:
    linear-gradient(
      135deg,
      #007bff,
      #7b2cff
    );

  color: white;

  font-size: 28px;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;

  box-shadow:
    0 4px 12px rgba(0,0,0,0.3),
    0 0 15px rgba(123,44,255,0.4);

  transition: all 0.3s ease;

  touch-action: none;

  user-select: none;

}


/* =========================
   BUTTON PRESS EFFECT
========================= */

.ai-mic-btn:active {

  transform: scale(0.95);

}


/* =========================
   LISTENING ANIMATION
========================= */

.ai-mic-btn.listening {

  animation: aiPulse 1.2s infinite;

}


@keyframes aiPulse {

  0% {

    transform: scale(1);

    box-shadow:
      0 0 0 0 rgba(123,44,255,0.6);

  }

  70% {

    transform: scale(1.08);

    box-shadow:
      0 0 0 18px rgba(123,44,255,0);

  }

  100% {

    transform: scale(1);

  }

}

.app-disclaimer {
  margin: 20px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #666;
  background: #f5f5f5;
  border-radius: 8px;
  text-align: center;
}


html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

body {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#playStoreBanner{
  display:none;
  align-items:center;
  justify-content:center;
  gap:10px;
  padding:10px;
  background:#e8f5e9;
  border-bottom:1px solid #ccc;
  font-size:14px;
  position:sticky;
  top:0;
  z-index:1000;
}

#closeBanner{
  border:none;
  background:none;
  font-size:18px;
  cursor:pointer;
  padding:0 5px;
}
