/* ==========================================================================
   Browser Calculator - Engineering Tool Styles
   Professional internal calculator for wellbore engineering
   ========================================================================== */

/* ==========================================================================
   1. Reset & Base Styles
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: #2d3748;
  background-color: #f7f8fa;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   2. Navigation Bar
   ========================================================================== */

nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background-color: #1a365d;
  color: #ffffff;
  padding: 1rem 2rem;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

nav a {
  color: #ffffff;
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s ease;
}

nav a:hover {
  opacity: 0.8;
}

nav .nav-title {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Offset content below fixed navigation */
main {
  margin-top: 70px;
  padding: 2rem;
}

/* ==========================================================================
   3. Container & Layout
   ========================================================================== */

.container {
  max-width: 900px;
  margin: 0 auto;
  background-color: #ffffff;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

/* ==========================================================================
   4. Landing Page - Calculator Cards Grid
   ========================================================================== */

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.calculator-card {
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  text-decoration: none;
  color: inherit;
  display: grid;
  grid-template-columns: auto 1fr;
}

.calculator-card:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #e2e8f0;
  padding: 0.25rem;
  width: 150px;
}

.card-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.calculator-card h2 {
  color: #1a365d;
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.calculator-card p {
  color: #4a5568;
  font-size: 0.95rem;
}

.card-wip {
  opacity: 0.6;
  pointer-events: none;
}

.wip-badge {
  display: inline-block;
  background-color: #ecc94b;
  color: #744210;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 0.4rem;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   5. Typography & Headings
   ========================================================================== */

h1 {
  color: #1a365d;
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.page-icon {
  width: 40px;
  height: 40px;
  vertical-align: middle;
  margin-right: 0.5rem;
  position: relative;
  top: -2px;
}

h2 {
  color: #1a365d;
  font-size: 1.5rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #4a6fa5;
}

h3 {
  color: #2d3748;
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.subtitle {
  color: #4a5568;
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

/* ==========================================================================
   6. Form Styling
   ========================================================================== */

form {
  margin-top: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

label {
  font-weight: 500;
  color: #2d3748;
  min-width: 180px;
  text-align: right;
}

input[type="number"],
input[type="text"],
select {
  width: 200px;
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e0;
  border-radius: 4px;
  font-size: 0.95rem;
  font-family: "Consolas", "Courier New", monospace;
  text-align: right;
  transition: border-color 0.2s ease;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  outline: none;
  border-color: #4a6fa5;
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

select {
  text-align: left;
  cursor: pointer;
}

/* Radio button groups */
.radio-group {
  display: flex;
  gap: 1.5rem;
  margin-left: 0;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.radio-option input[type="radio"] {
  width: auto;
  margin: 0;
  cursor: pointer;
}

.radio-option label {
  min-width: auto;
  text-align: left;
  cursor: pointer;
  font-weight: 400;
}

/* Units display */
.units {
  color: #718096;
  font-size: 0.875rem;
  margin-left: 0.5rem;
}

/* ==========================================================================
   7. Buttons
   ========================================================================== */

.button-group {
  margin-top: 2rem;
  display: flex;
  gap: 1rem;
  justify-content: flex-start;
}

button,
.btn-primary,
.btn-secondary {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

button[type="submit"],
.btn-primary {
  background-color: #1a365d;
  color: #ffffff;
}

button[type="submit"]:hover,
.btn-primary:hover {
  background-color: #2d4a7c;
}

button[type="button"],
.btn-secondary {
  background-color: transparent;
  color: #1a365d;
  border: 2px solid #1a365d;
}

button[type="button"]:hover,
.btn-secondary:hover {
  background-color: #f7f8fa;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==========================================================================
   8. Results Section
   ========================================================================== */

.results-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid #e2e8f0;
  display: none; /* Hidden by default, shown via JavaScript */
}

.results-section.visible {
  display: block;
}

.result-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  font-weight: 500;
  color: #2d3748;
}

.result-value {
  font-family: "Consolas", "Courier New", monospace;
  font-weight: 600;
  color: #1a365d;
  text-align: right;
}

/* ==========================================================================
   9. Tables
   ========================================================================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  margin-bottom: 2rem;
}

thead {
  background-color: #1a365d;
  color: #ffffff;
}

th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  border: 1px solid #2d4a7c;
}

td {
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  font-family: "Consolas", "Courier New", monospace;
}

tbody tr:nth-child(even) {
  background-color: #f7f8fa;
}

tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

tbody tr:hover {
  background-color: #edf2f7;
}

/* Numeric columns */
td.numeric {
  text-align: right;
  font-weight: 500;
}

/* Section headers within tables */
tr.section-header td {
  background-color: #4a6fa5;
  color: #ffffff;
  font-weight: 600;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-align: left;
  padding: 0.5rem 1rem;
}

/* ==========================================================================
   10. Status Indicators
   ========================================================================== */

.status-good {
  color: #38a169;
  font-weight: 700;
}

.status-marginal {
  color: #d69e2e;
  font-weight: 700;
}

.status-fail {
  color: #e53e3e;
  font-weight: 700;
}

.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.good {
  background-color: #c6f6d5;
  color: #22543d;
}

.status-badge.marginal {
  background-color: #feebc8;
  color: #744210;
}

.status-badge.fail {
  background-color: #fed7d7;
  color: #742a2a;
}

/* ==========================================================================
   11. Footer
   ========================================================================== */

footer {
  max-width: 900px;
  margin: 3rem auto 2rem;
  padding: 1.5rem 2rem;
  border-top: 1px solid #e2e8f0;
  color: #718096;
  font-size: 0.875rem;
  text-align: center;
}

footer p {
  margin-bottom: 0.5rem;
}

.standards-reference {
  font-style: italic;
  color: #a0aec0;
  font-size: 0.8rem;
}

/* ==========================================================================
   12. Utility Classes
   ========================================================================== */

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.hidden {
  display: none;
}

.visible {
  display: block;
}

/* ==========================================================================
   13. Responsive Design
   ========================================================================== */

/* Tablet: 600px - 900px */
@media (min-width: 600px) and (max-width: 900px) {
  .form-group {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 1rem;
  }

  label {
    text-align: right;
  }

  input[type="number"],
  input[type="text"],
  select {
    width: 100%;
    max-width: 300px;
  }
}

/* Mobile: < 600px */
@media (max-width: 600px) {
  .card-icon {
    width: 72px;
    padding: 0.75rem;
  }

  .card-body {
    padding: 1rem;
  }

  nav {
    padding: 1rem;
  }

  main {
    margin-top: 60px;
    padding: 1rem;
  }

  .container {
    padding: 1rem;
  }

  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .form-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  label {
    min-width: auto;
    text-align: left;
  }

  input[type="number"],
  input[type="text"],
  select {
    width: 100%;
  }

  .radio-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .button-group {
    flex-direction: column;
  }

  button,
  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  table {
    font-size: 0.875rem;
  }

  th, td {
    padding: 0.5rem;
  }

  .result-item {
    flex-direction: column;
    gap: 0.25rem;
  }

  .result-value {
    text-align: left;
  }
}

/* ==========================================================================
   14. Print Stylesheet
   ========================================================================== */

@media print {
  /* Hide navigation and interactive elements */
  nav,
  button,
  .btn-primary,
  .btn-secondary,
  .button-group {
    display: none !important;
  }

  /* Remove fixed positioning */
  main {
    margin-top: 0;
  }

  /* Expand content */
  .container {
    max-width: 100%;
    box-shadow: none;
    padding: 0;
  }

  /* Hide form inputs, show only results */
  form {
    display: none;
  }

  .results-section {
    display: block !important;
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }

  /* Clean table borders */
  table {
    border: 2px solid #000;
  }

  th {
    background-color: #000 !important;
    color: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  td {
    border: 1px solid #000;
  }

  /* Remove alternating row colors for clarity */
  tbody tr {
    background-color: #fff !important;
  }

  /* Ensure status colors print */
  .status-good {
    color: #000 !important;
    text-decoration: underline;
  }

  .status-marginal {
    color: #000 !important;
    font-style: italic;
  }

  .status-fail {
    color: #000 !important;
    font-weight: 900;
  }

  /* Page breaks */
  h2 {
    page-break-after: avoid;
  }

  table {
    page-break-inside: avoid;
  }

  /* Footer */
  footer {
    margin-top: 2rem;
    border-top: 2px solid #000;
  }
}
