/* ═══════════════════════════════════════════════════════════════════════════════
   GLOBAL MOBILE-FIRST RESPONSIVE CSS
   Covers: 320px, 375px, 425px, 768px, 1024px breakpoints
═══════════════════════════════════════════════════════════════════════════════ */

:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color-scheme: normal;
  text-rendering: optimizeLegibility;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: hidden !important;
}

img, picture, video, iframe, svg, canvas {
  max-width: 100%;
  height: auto;
  display: block;
}

button, input, textarea, select {
  font: inherit;
  min-width: 0;
}

button, .button, .btn, .submit, .sub {
  min-height: 44px;
  line-height: 1.2;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}

input, textarea, select {
  max-width: 100%;
  width: 100%;
  padding: 0.5rem;
  border-radius: 4px;
}

/* ── Base layout classes ── */
.card, .container, .content, .section, .page, .wrapper, 
.complaintDetails, .upperInfo, .lowerInfo, .lowInfo, 
.field-group, .form-group {
  width: 100%;
  max-width: 100%;
}

.navbar, .navi, .menu, .menus, .tabs, .header, .topbar, 
.toolbar-btns, .drawer-actions, .notification-row, .profile-row {
  flex-wrap: wrap;
}

.break-word {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* ═══════════════════════════════════════════════════════════════════════════════
   EXTRA SMALL (320px - 374px): Mobile phones
═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 374px) {
  body {
    font-size: 0.875rem;
    line-height: 1.5;
  }
  
  h1 { font-size: 1.25rem; }
  h2 { font-size: 1.1rem; }
  h3 { font-size: 1rem; }
  h4, h5, h6 { font-size: 0.95rem; }

  /* Navigation */
  header {
    padding: 0.25rem !important;
  }
  
  .navbar, .header {
    gap: 0.5rem;
  }
  
  .logo img {
    width: 36px !important;
    height: 36px !important;
  }
  
  .logo .hsbis,
  .navi a {
    font-size: 0.8rem;
  }
  
  .navi {
    gap: 0.5rem;
    padding: 0.25rem 0;
  }

  /* Forms and inputs */
  input, textarea, select {
    padding: 0.4rem 0.5rem;
    font-size: 1rem; /* Prevents zoom on focus */
  }
  
  button, .btn, .submit, .sub {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    min-height: 40px;
  }

  /* Layout */
  .page, .container, .card, .wrapper {
    padding-left: 8px;
    padding-right: 8px;
    margin-left: 0;
    margin-right: 0;
  }

  /* Sections */
  .section, .row, .grid {
    gap: 0.5rem;
  }

  /* Forms */
  .field, .form-group, .info {
    margin-bottom: 0.75rem;
    gap: 0.25rem;
  }

  .upperInfo {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .info input, .info select {
    width: 100% !important;
  }

  /* Overflow prevention */
  html, body {
    overflow-x: hidden;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   SMALL (375px - 424px): Mobile phones  
═══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 375px) and (max-width: 424px) {
  body {
    font-size: 0.9rem;
  }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1.05rem; }

  .page, .container, .card, .wrapper {
    padding-left: 12px;
    padding-right: 12px;
  }

  .field, .form-group {
    margin-bottom: 1rem;
  }

  input, textarea, select {
    padding: 0.5rem;
  }

  button, .btn, .submit, .sub {
    padding: 0.6rem 1.2rem;
    min-height: 42px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   MEDIUM (425px - 767px): Larger mobile phones & small tablets
═══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 425px) and (max-width: 767px) {
  body {
    font-size: 0.92rem;
  }

  h1 { font-size: 1.45rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.1rem; }

  .page, .container, .card, .wrapper {
    padding-left: 16px;
    padding-right: 16px;
  }

  .field, .form-group {
    margin-bottom: 1.2rem;
  }

  input, textarea, select {
    padding: 0.55rem 0.75rem;
    font-size: 1rem;
  }

  button, .btn, .submit, .sub {
    padding: 0.7rem 1.4rem;
    min-height: 44px;
  }

  /* Grid adjustments */
  .grid-two, .grid-three {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }

  .grid-three {
    grid-template-columns: 1fr 1fr;
  }

  .grid-three > :nth-child(3n) {
    grid-column: 1 / -1;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   TABLET (768px - 1023px): iPads and small laptops
═══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 1023px) {
  body {
    font-size: 0.95rem;
  }

  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  h3 { font-size: 1.15rem; }

  .navbar, .header, .topbar, .menu, .tabs, .drawer-actions, 
  .card-top, .modal-header, .modal-actions, .section-row {
    flex-direction: row;
    align-items: center;
  }

  .navbar .navi, .navbar ul, .menu, .toolbar-btns {
    width: auto;
    justify-content: flex-start;
    gap: 1rem;
  }

  .navi li {
    width: auto;
  }

  .field, .form-group, .row, .grid, .grid-two, .grid-three {
    display: grid;
    width: 100%;
  }

  .grid-two {
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
  }

  .grid-three {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.2rem;
  }

  .grid-two > *, .grid-three > * {
    width: 100%;
    min-width: 0;
  }

  .page, .container, .card, .wrapper {
    padding-left: 20px;
    padding-right: 20px;
  }

  .safe-area {
    padding-left: 20px;
    padding-right: 20px;
  }

  /* Info fields in grid */
  .upperInfo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.2rem;
  }

  .lowerInfo {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   DESKTOP (1024px+): Large screens
═══════════════════════════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  body {
    font-size: 1rem;
  }

  h1 { font-size: 1.8rem; }
  h2 { font-size: 1.4rem; }
  h3 { font-size: 1.2rem; }

  .navbar, .header, .menu {
    flex-direction: row;
    align-items: center;
  }

  .page, .container, .card, .wrapper {
    padding-left: 24px;
    padding-right: 24px;
    margin: 0 auto;
    max-width: 1200px;
  }

  .safe-area {
    padding-left: 24px;
    padding-right: 24px;
  }

  .grid-two {
    grid-template-columns: 1fr 1fr;
  }

  .grid-three {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .upperInfo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LAYOUT RESPONSIVE FIXES
═══════════════════════════════════════════════════════════════════════════════ */

/* Hide pic on mobile */
@media (max-width: 900px) {
  .layout {
    flex-direction: column !important;
  }
  .pic {
    display: none !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   FORM AND COMMON ELEMENT FIXES
═══════════════════════════════════════════════════════════════════════════════ */

/* Forms - responsive fixes for all form pages */
.complaintForm, .feedbackForm, .residencyForm, .clearanceForm,
.reportForm, .blotterForm, .registrationForm, .serviceForm {
  position: static !important;
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  height: auto !important;
  padding: 1rem;
  border-radius: 4px;
}

.complaintDetails, .feedbackDetails, .formDetails, .formContainer {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  margin: 0 !important;
  padding: 1rem !important;
}

/* Header sizing - make responsive */
header img {
  max-height: 60px;
  max-width: 60px;
}

/* Background logo responsive */
.lostop img {
  width: 100% !important;
  height: auto !important;
  max-width: 200px !important;
}

/* Navigation fixes */
.navbar {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.navbar ul, .navbar .navi {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.navbar a, .navbar button {
  white-space: nowrap;
  font-size: clamp(0.75rem, 2vw, 1rem);
}

/* Form inputs consistency */
input[type="text"], input[type="email"], input[type="date"], 
input[type="number"], input[type="password"], input[type="tel"],
select, textarea {
  max-width: 100%;
  width: 100%;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 1rem; /* Prevent zoom on mobile */
  border: 1px solid #ccc;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* Button consistency */
button, .btn, .submit, .sub, [type="submit"] {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-size: clamp(0.875rem, 2vw, 1rem);
  min-height: 44px;
  border-radius: 4px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

/* Grid layout fixes */
.upperInfo, .infoGrid, .formGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  width: 100%;
}

.info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.info label {
  font-weight: 600;
  font-size: 0.95rem;
}

.info input, .info select {
  width: 100% !important;
}

/* Dropdown menu fixes */
.dropdown .content {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  top: auto !important;
  bottom: 0 !important;
  border-radius: 16px 16px 0 0;
  max-height: 80vh;
  overflow-y: auto;
  width: 100% !important;
  min-width: auto !important;
}

/* Section alignment */
.lowerInfo, .lowInfo, .section {
  width: 100%;
  margin: 1rem 0;
  padding: 0;
}

.lowInfo h4 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  line-height: 1.6;
}

.lowInfo textarea {
  width: 100%;
}

/* Footer fixes */
.footer-links, footer {
  flex-direction: column;
  gap: 1rem;
  align-items: center;
  text-align: center;
}

.footer-link-button, .footer-links a, .footer-links button {
  width: 100%;
  display: block;
  padding: 0.75rem;
}

/* Table responsive */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  font-size: clamp(0.75rem, 2vw, 0.95rem);
}

/* Card and container fixes */
.card {
  margin-bottom: 1rem;
  padding: 1rem;
}

.container {
  margin: 0 auto;
  width: 100%;
  padding: 0 1rem;
}

/* Prevent all overflow */
body, html {
  overflow-x: hidden !important;
  width: 100%;
  max-width: 100%;
}

/* Additional responsive breakpoint tweaks */

/* ═══════════════════════════════════════════════════════════════════════════════
   UNIVERSAL MEDIA QUERIES FOR MOBILE
═══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Hide desktop-only elements */
  .desktop-only {
    display: none !important;
  }

  /* Navigation fixes */
  header {
    width: 100% !important;
    overflow-x: visible;
    z-index: 100;
  }

  .navbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .navi {
    width: 100%;
    flex-direction: column;
    gap: 0.25rem;
  }

  .navi a {
    display: block;
    padding: 0.5rem;
  }

  .dropdown {
    width: 100%;
  }

  .menu {
    width: 100%;
    margin-left: 0;
  }

  /* Form fixes */
  .complaintForm,
  .feedbackForm,
  .residencyForm,
  .clearanceForm {
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    height: auto !important;
  }

  .complaintDetails,
  .feedbackDetails {
    width: 100% !important;
    margin: 0 !important;
    padding: 1rem !important;
    height: auto !important;
  }

  .info input,
  .info select,
  .lowInfo textarea {
    width: 100% !important;
  }

  textarea {
    min-height: 100px;
    resize: vertical;
  }

  /* Remove unnecessary margins */
  .cut {
    margin-top: 1rem;
  }

  .lowerInfo {
    margin: 1rem 0;
  }

  .lowInfo {
    margin: 0.5rem 0;
  }

  /* Footer alignment */
  .dash-footer,
  .footer-links,
  footer {
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    text-align: center;
  }

  .footer-link-button,
  .footer-links a,
  .footer-links button {
    width: 100%;
    display: block;
  }

  /* Card and content alignment */
  .card {
    margin-bottom: 1rem;
  }

  /* Remove horizontal scrolling */
  body, html {
    overflow-x: hidden !important;
    width: 100%;
  }

  /* Prevent layout shift */
  ::-webkit-scrollbar {
    width: 8px;
  }
}

@media (max-width: 480px) {
  /* Extra small padding for very small screens */
  .page, .container, .card, .wrapper {
    padding-left: 8px;
    padding-right: 8px;
  }

  /* Reduce gaps further */
  .section, .row, .grid {
    gap: 0.5rem;
  }

  /* Ensure text doesn't overflow */
  p, span, label, button {
    word-break: break-word;
  }

  /* Ensure header image doesn't take too much space */
  header img {
    max-height: 50px;
    max-width: 50px;
  }

  header h2 {
    font-size: 0.9rem;
  }

  /* Buttons take full width on extra small */
  button, .btn, .submit, .sub {
    width: 100%;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════════
   LAYOUT RESPONSIVE FIXES
═══════════════════════════════════════════════════════════════════════════════ */

/* Hide pic on mobile */
@media (max-width: 900px) {
  .layout {
    flex-direction: column !important;
  }
  .pic {
    display: none !important;
  }
}

