/**
 * Responsive CSS for Freeside Self-Service Portal
 * NMICA Requirement - February 2026
 *
 * Mobile-first responsive design for customer-facing portal.
 * Complements default.css without breaking existing desktop layout.
 */

/* ============================================================
   Skip Navigation (Accessibility)
   ============================================================ */
.skip-nav {
  position: absolute;
  top: -40px;
  left: 0;
  background: #000;
  color: #fff;
  padding: 8px 16px;
  z-index: 100;
  font-size: 14px;
  transition: top 0.2s;
}
.skip-nav:focus {
  top: 0;
}

/* ============================================================
   Base Responsive Adjustments
   ============================================================ */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: #333;
}

header[role="banner"] {
  background: #2c3e50;
  color: #fff;
  padding: 16px 20px;
}

header h1 {
  margin: 0;
  font-size: 1.5em;
  font-weight: 600;
}

main[role="main"] {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

footer[role="contentinfo"] {
  background: #f5f5f5;
  border-top: 1px solid #ddd;
  padding: 20px;
  text-align: center;
  font-size: 0.85em;
  color: #666;
  margin-top: 40px;
}

footer nav {
  margin-bottom: 8px;
}

footer a {
  color: #2c3e50;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.copyright {
  margin: 8px 0 0;
}

/* ============================================================
   Form Improvements
   ============================================================ */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  max-width: 400px;
  padding: 10px 12px;
  font-size: 16px; /* Prevents iOS zoom-on-focus */
  border: 1px solid #ccc;
  border-radius: 4px;
  margin: 4px 0 12px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #2c3e50;
  outline-offset: 2px;
  border-color: #2c3e50;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  color: #333;
}

input[type="submit"],
button {
  background: #2c3e50;
  color: #fff;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 4px;
  cursor: pointer;
  min-height: 44px; /* WCAG touch target */
  min-width: 44px;
}

input[type="submit"]:hover,
button:hover {
  background: #34495e;
}

input[type="submit"]:focus,
button:focus {
  outline: 3px solid #3498db;
  outline-offset: 2px;
}

/* ============================================================
   Table Responsive
   ============================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th {
  font-weight: 600;
  white-space: nowrap;
}

/* ============================================================
   Error / Success Messages
   ============================================================ */
.error-message,
.alert-error {
  background: #fee;
  border: 1px solid #fcc;
  color: #c00;
  padding: 12px 16px;
  border-radius: 4px;
  margin: 16px 0;
}

.success-message,
.alert-success {
  background: #efe;
  border: 1px solid #cfc;
  color: #060;
  padding: 12px 16px;
  border-radius: 4px;
  margin: 16px 0;
}

/* ============================================================
   Profile Form (personal.php)
   ============================================================ */
.profile-form fieldset {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 20px;
  margin: 0 0 20px;
}

.profile-form legend {
  font-weight: 600;
  font-size: 1.1em;
  padding: 0 8px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.form-group {
  flex: 1 1 200px;
  min-width: 0;
}

/* ============================================================
   Mobile: Small screens (< 768px)
   ============================================================ */
@media screen and (max-width: 767px) {
  main[role="main"] {
    padding: 12px;
  }

  header h1 {
    font-size: 1.2em;
  }

  /* Stack form fields vertically */
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  select,
  textarea {
    max-width: 100%;
  }

  /* Responsive tables */
  table, thead, tbody, th, td, tr {
    display: block;
  }

  thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  tr {
    margin: 0 0 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px;
  }

  td {
    border: none;
    position: relative;
    padding-left: 40%;
    text-align: right;
  }

  td::before {
    content: attr(data-label);
    position: absolute;
    left: 12px;
    font-weight: 600;
    text-align: left;
  }

  /* Navigation stacks */
  nav ul {
    flex-direction: column;
  }

  nav li {
    margin: 4px 0;
  }
}

/* ============================================================
   Tablet: Medium screens (768px - 1024px)
   ============================================================ */
@media screen and (min-width: 768px) and (max-width: 1024px) {
  main[role="main"] {
    padding: 16px;
  }

  .form-row {
    gap: 12px;
  }

  .form-group {
    flex: 1 1 45%;
  }
}

/* ============================================================
   High contrast focus indicators (Accessibility)
   ============================================================ */
:focus-visible {
  outline: 3px solid #3498db;
  outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print styles */
@media print {
  header, footer, nav, .skip-nav {
    display: none;
  }
  main {
    padding: 0;
  }
}
