/* MASTERPIECE DESIGN SYSTEM: THE "PRECISION ENGINEER" THEME */
/* Applied Psychology: Trust, competence, innovation, and clarity */

/* 1. FONTS moved to HTML HEAD for performance */

:root {
  /* COLOR PSYCHOLOGY PALETTE - Synced with Tailwind Config */
  
  /* PRIMARY: "Deep Ocean Navy" */
  --primary: #0F172A; 
  
  /* SECONDARY: "Industrial Teal" */
  --secondary: #008F4C;
  
  /* ACCENT: "Kinetic Lime" */
  --accent: #D4E157; 
  
  /* NEUTRAL */
  --bg-surface: #FFFFFF;
  --bg-subtle: #F8FAFC; 
  --text-main: #334155; 
  --text-heading: #1E293B;
}

/* Utility Overrides */
.bg-primary { background-color: var(--primary) !important; }
.text-primary { color: var(--primary) !important; }

/* 2. TYPOGRAPHY SYSTEM (The Voice of Authority) */
body {
    font-family: 'DM Sans', sans-serif !important;
    color: var(--text-main) !important;
    line-height: 1.6 !important; /* Improved readability */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, header a.text-2xl {
    font-family: 'Outfit', sans-serif !important; /* Modern, humanist, legible */
    letter-spacing: -0.01em !important; /* Slightly relaxed */
    line-height: 1.2 !important;
}

/* 3. RESPONSIVE UTILITIES */
@media (min-width: 640px) {
  .sm\:flex { display: flex !important; }
  .sm\:hidden { display: none !important; }
}

/* ---------------------------------------------------- */
/* THE HEADER: "Architecture & Clarity"                 */
/* ---------------------------------------------------- */

header.fixed, header {
  background: #ffffff !important; 
  backdrop-filter: blur(12px) !important;
  border-bottom: 1px solid rgba(226, 232, 240, 0.6) !important; 
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.02) !important; 
  height: 80px !important;
}

/* Logo - The Anchor */
header a.text-2xl {
  color: var(--primary) !important;
  font-weight: 800 !important;
  text-transform: uppercase !important;
  font-size: 1.35rem !important;
  letter-spacing: -0.5px !important;
  /* Visual balance: Text logo acts as a solid block */
}

/* Navigation Links - Clean Minimalist */
/* Navigation Links - Clean Minimalist */
header nav div.hidden a,
header nav .group-link {
  color: #475569 !important; /* Slate 600 - More precise formatting */
  font-family: 'DM Sans', sans-serif !important;
  font-weight: 500 !important;
  font-size: 0.95rem !important; /* Slightly larger for readability */
  padding: 8px 12px !important; /* Reduced side padding */
  border-radius: 0px !important; /* No radius for underline style */
  transition: color 0.2s ease !important;
  background: transparent !important;
  position: relative !important;
  letter-spacing: -0.01em !important;
}

/* Hover: Elegant Underline */
header nav div.hidden a:hover,
header nav .group-link:hover {
  color: #0F172A !important; /* Navy */
  background: transparent !important;
  transform: none !important;
}

header nav div.hidden a::after,
header nav .group-link::after {
  content: '' !important;
  position: absolute !important;
  width: 0 !important;
  height: 2px !important;
  bottom: 0px !important;
  left: 0 !important;
  background-color: var(--secondary) !important; /* Green line */
  transition: width 0.3s ease !important;
}

header nav div.hidden a:hover::after,
header nav .group-link:hover::after {
  width: 100% !important;
}

/* Remove old underline styles */
header nav span.bg-white,
header nav a:hover span.bg-white {
    display: none !important;
}

/* Arrow Icon */
header nav svg.fill-current {
  fill: #94A3B8 !important; /* Light Slate - De-emphasized */
  transition: fill 0.3s ease, transform 0.3s ease !important;
}
header nav .group-link:hover svg.fill-current {
  fill: var(--secondary) !important;
  transform: rotate(180deg) !important; /* Active feedback */
}

/* 4. THE "CONTACT" BUTTON: Option A "The Executive" */
.btn-contact-custom {
  background-color: #0F172A !important; /* Navy Background */
  color: #D4E157 !important; /* Lime Text */
  font-family: 'Outfit', sans-serif !important;
  font-weight: 700 !important;
  font-size: 0.8rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.05em !important;
  border: none !important; /* Solid look */
  border-radius: 9999px !important;
  padding: 0 28px !important;
  box-shadow: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -1px rgba(15, 23, 42, 0.06) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-decoration: none !important;
  height: 42px !important;
}

/* Hover Effect - Lift & Glow */
.btn-contact-custom:hover {
  background-color: #1E293B !important; /* Slightly lighter navy for feedback */
  color: #D4E157 !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 10px 15px -3px rgba(15, 23, 42, 0.15), 0 4px 6px -2px rgba(15, 23, 42, 0.1) !important;
}

/* 5. NAVIGATION ACTIVE STATE */
/* --------------------------------------------------------- */

/* Indicador activo en links normales del nav */
header nav div.hidden a.active,
header nav .group-link.active {
  color: var(--secondary) !important;
  font-weight: 700 !important;
}
header nav div.hidden a.active::after,
header nav .group-link.active::after {
  width: 100% !important;
  background-color: var(--secondary) !important;
}

/* ---- MOBILE MENU: Estilos ---- */
#mobile-menu { 
  background: #ffffff !important; 
  padding-top: 1rem !important;
}

#mobile-menu a:not(.btn-contact-custom) {
    color: #0F172A !important;
}

/* Mobile CONTACTAR button: ensure lime text on dark background */
#mobile-menu .border-t a {
    color: #D4E157 !important;
}
footer.bg-secondary {
    background: #0f172a !important; /* Slate 900 */
    border-top: 5px solid var(--secondary) !important;
}

/* 4.1 HERO CTA BUTTON: Big, Bold, Impactful */
.btn-hero-cta {
  background-color: #0F172A !important;
  color: #D4E157 !important;
  font-family: 'Outfit', sans-serif !important;
  font-weight: 700 !important;
  font-size: 0.95rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.1em !important;
  border: 2px solid #D4E157 !important;
  border-radius: 50px !important;
  padding: 14px 40px !important;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.4) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  text-decoration: none !important;
  position: relative !important;
  overflow: hidden !important;
  z-index: 10 !important;
}

.btn-hero-cta:hover {
  background-color: #D4E157 !important;
  color: #0F172A !important;
  border-color: #D4E157 !important;
  transform: translateY(-4px) !important;
  box-shadow: 0 20px 35px -5px rgba(15, 23, 42, 0.5), 0 0 20px rgba(212, 225, 87, 0.4) !important; /* Glow */
}

/* 6. STATS CARDS: Interactive Data */
.stat-card {
  padding: 1.5rem;
  border-radius: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  cursor: default;
  position: relative;
}

.stat-card:hover {
  background-color: #F8FAFC; /* Lightest Slate highlight */
  box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.08); /* Soft lift */
  transform: translateY(-5px);
  border-color: rgba(15, 23, 42, 0.03);
}

.stat-card .stat-number {
  transition: color 0.3s ease;
}

.stat-card:hover .stat-number {
  color: #008F4C !important; /* Change number to Secondary Green */
}

/* Decorative Accent Line on Hover */
.stat-card::after {
  content: '';
  display: block;
  width: 0;
  height: 4px;
  background: #D4E157; /* Lime Accent */
  margin: 12px auto 0;
  transition: width 0.3s ease;
  border-radius: 2px;
}

.stat-card:hover::after {
  width: 40px; /* Expands smoothly */
}

/* 7. EXPERTISE CARDS: Icon Interaction */
.expertise-card .icon-box {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: #0F172A !important; /* Default: Navy */
}

.expertise-card:hover .icon-box {
  background-color: #D4E157 !important; /* Hover: Lime Accent */
  transform: scale(1.1); /* Subtle Pop only, no rotation */
  box-shadow: 0 10px 15px -3px rgba(212, 225, 87, 0.4);
}

.expertise-card .icon-svg {
  transition: all 0.3s ease;
  color: #ffffff !important; /* Default: White */
}

.expertise-card:hover .icon-svg {
  color: #0F172A !important; /* Hover: Navy for contrast */
}

/* TOOL SPECIFIC STYLES - RESTORED */
.card {
  background-color: #ffffff;
  border-radius: 0.75rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 2rem;
  margin-bottom: 2rem;
  border: 1px solid #e2e8f0;
}

.input-row {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .input-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.input-group {
  display: flex;
  flex-direction: column;
}

.input-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.5rem;
}
.input-group label.required::after {
  content: ' *';
  color: #ef4444;
}

.input-group input,
.input-group select {
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid #94a3b8; /* Increased contrast for visibility */
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25rem;
  color: #111827;
  background-color: #fff;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.input-group input:hover,
.input-group select:hover {
  border-color: #64748b; /* Slate 500 on hover */
}

.input-group input:focus,
.input-group select:focus {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.5);
}

.calculation-formula {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.875rem;
  color: #475569;
  margin-top: 1.5rem;
}

.factors-info {
  background-color: #eff6ff;
  border-left: 4px solid #3b82f6;
  padding: 1rem;
  border-radius: 0 0.5rem 0.5rem 0;
  margin: 1.5rem 0;
}
.factors-info h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #1e3a8a;
  margin-bottom: 0.5rem;
}
.factors-info p {
  margin-bottom: 0;
  padding: 0.75rem 0;
  font-size: 0.875rem;
  color: #1e293b;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #cbd5e1; /* Cell border look */
}
.factors-info p:last-child {
  border-bottom: none;
}
.factor-value {
  font-weight: 700;
  color: #0f172a;
}

.error-message {
  display: none;
  font-size: 0.75rem;
  color: #dc2626;
  margin-top: 0.25rem;
}

button#calculateBtn, button[onclick='calculate()'] {
  background-color: var(--primary);
  color: var(--accent);
  font-weight: 700;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
  width: 100%;
}
button#calculateBtn:hover, button[onclick='calculate()']:hover {
  background-color: #1e293b;
}

button#clearBtn, button[onclick='clearFields()'] {
  background-color: #64748b;
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
}
button#clearBtn:hover, button[onclick='clearFields()']:hover {
  background-color: #475569;
}

/* Table Improvements */
.table-container {
    overflow-x: auto;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem; /* Slightly smaller for density */
    text-align: center; /* Center align for numbers */
}

table th {
    background-color: #f1f5f9; /* Slate 100 */
    color: #0f172a; /* Slate 900 */
    font-weight: 700;
    padding: 0.75rem 0.5rem;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

table td {
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    color: #334155;
}

/* First columns (info) left aligned or distinct */
table td:nth-child(1),
table td:nth-child(2),
table td:nth-child(3),
table td:nth-child(4) {
    text-align: left;
    background-color: #fff; /* Keep sticky info white or neutral */
    font-weight: 500;
}

table tr:hover td {
    background-color: rgba(241, 245, 249, 0.5); /* Subtle highlight on row */
}

/* Status Colors - As requested */
.pressure-ok {
    background-color: #dcfce7 !important; /* Green 100 */
    color: #15803d !important; /* Green 700 */
    font-weight: 700 !important;
}

.pressure-fail {
    background-color: #fee2e2 !important; /* Red 100 */
    color: #b91c1c !important; /* Red 700 */
    font-weight: 700 !important;
}

/* Legend Styles matching new classes */
.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: 0.25rem;
    border: 1px solid rgba(0,0,0,0.1);
}

/* Grade Colors for Legend */
.grade-A { background-color: #e2e8f0; }
.grade-B { background-color: #cbd5e1; }
.grade-X42 { background-color: #94a3b8; }
.grade-X52 { background-color: #64748b; }
.grade-X60 { background-color: #475569; }
.grade-X65 { background-color: #334155; }
.grade-X70 { background-color: #1e293b; }

/* ---------------------------------------------------- */
/* GAS PROPERTIES TOOL STYLES                           */
/* ---------------------------------------------------- */

.title-box {
  background-color: var(--primary);
  color: white;
  padding: 2rem;
  border-radius: 0.75rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.title-box h1 {
  color: white !important;
  margin-bottom: 0.5rem;
}

.composition-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.comp-item {
  display: flex;
  flex-direction: column;
}

.comp-item label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #64748b;
  margin-bottom: 0.25rem;
}

.comp-item input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.375rem;
  font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
}

.comp-item input:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(0, 143, 76, 0.1); /* Green glow */
  outline: none;
}

.units {
  color: #94a3b8;
  font-weight: 400;
  font-size: 0.75rem;
  margin-left: 4px;
}

/* Visualization Chart */
.chart-container {
  height: 240px;
  display: flex;
  align-items: flex-end; /* Bars grow from bottom */
  justify-content: center;
  gap: 8px; /* Space between bars */
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 1rem 1rem 0 1rem; /* Padding bottom 0 for bars to sit flush maybe? no, flex alignment handles it */
  margin-top: 1rem;
  position: relative;
  overflow: hidden;
}

.chart-bar {
  flex: 1; 
  background-color: var(--secondary); /* Brand green */
  min-width: 20px;
  max-width: 50px;
  border-radius: 4px 4px 0 0;
  transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); /* Bouncy effect */
  position: relative;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.chart-bar:hover {
  background-color: var(--accent); /* Lime on hover */
  transform: translateY(-2px);
  cursor: help;
}

#chartLabels span {
  width: 50px; /* Align roughly with max-width of bars */
  text-align: center;
  display: inline-block;
  font-weight: 600;
  color: var(--text-heading);
}

/* ---------------------------------------------------- */
/* PRINT MEDIA STYLES - "Memoria de Cálculo"            */
/* ---------------------------------------------------- */
@media print {
  /* Hide UI elements not needed in report */
  header, nav, footer, .no-print, 
  .btn-contact-custom, #mobile-menu-button, #mobile-nav,
  button, .input-group button, #calculateBtn, #clearBtn, 
  .print-btn-hide, .floating-whatsapp {
    display: none !important;
  }
  
  /* Reset body for paper */
  body {
    background: white !important;
    color: black !important;
    font-size: 11pt;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Expand containers */
  .container, .max-w-7xl, .w-full, main, section {
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: auto !important;
  }

  /* Card styling for clean print */
  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
    margin-bottom: 20px !important;
    break-inside: avoid; /* Prevent splitting cards across pages */
  }

  /* Inputs: Show values as text */
  input, select, textarea {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
    font-weight: bold;
    color: black !important;
    /* Attempt to remove arrow from selects */
    appearance: none; 
    -webkit-appearance: none;
  }
  
  /* Hide placeholders if empty? Hard to do with CSS only, but values will show */

  /* Ensure colors print */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Show the injected footer */
  #print-footer {
    display: block !important;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    border-top: 2px solid #008F4C;
    padding-top: 10px;
    background: white;
    z-index: 9999;
  }
  
  /* Adjust main content to not overlap footer */
  body {
    padding-bottom: 50px !important;
  }
}

/* Hide print footer on screen */
#print-footer { display: none; }

/* ---------------------------------------------------- */
/* ACCESSIBILITY & PERFORMANCE OPTIMIZATIONS            */
/* ---------------------------------------------------- */

/* Focus-visible for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--secondary) !important;
  outline-offset: 2px !important;
  border-radius: 4px;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Minimum touch target size for mobile (48x48) */
@media (max-width: 640px) {
  #mobile-menu a,
  header nav a,
  button {
    min-height: 48px;
    display: flex;
    align-items: center;
  }
}
