/**
 * Merged CSS file for Solar Calculator
 */

:root {
  --primary: #2c3e50;
  --primary-light: #3498db;
  --secondary: #27ae60;
  --accent: #e74c3c;
  --text: #333;
  --light: #f5f5f5;
  --white: #ffffff;
  --gray: #ecf0f1;
  --dark-gray: #bdc3c7;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  --border-radius: 10px;
  --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
  font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
  line-height: 1.7;
  color: var(--text);
  background-color: var(--light);
  padding: 2rem 1rem;
  min-height: 100vh;
  background-image: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
  background-attachment: fixed; /* Keep background fixed when scrolling */
  background-size: cover;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: url('cal.png');
  background-repeat: repeat;
  background-size: 80px 80px;
  opacity: 0.01;
  z-index: -1;
  pointer-events: none;
}

/* Enhanced text effects */
.text-accent {
  color: var(--accent);
  background: linear-gradient(45deg, var(--accent), var(--primary-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

/* Fade-in animation */
.fade-in {
  opacity: 0;
  animation: fadeIn 1.2s ease-in-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

h1, h2, h3 {
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 1.5rem;
  text-align: center;
}

h1 {
  font-size: 2.5rem;
  position: relative;
  padding-bottom: 1rem;
  margin-bottom: 2rem;
  transition: var(--transition);
}

h1::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 4px;
  background: linear-gradient(90deg, var(--secondary), var(--primary-light));
  border-radius: 2px;
  animation: expand 2s ease-out forwards;
}

@keyframes expand {
  from { width: 0; }
  to { width: 100px; }
}

h1:hover {
  transform: scale(1.03);
}

h1 i {
  margin-right: 10px;
  animation: solarSpin 10s infinite linear;
}

@keyframes solarSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

h2 {
  font-size: 1.8rem;
  margin-top: 2rem;
  color: var(--primary-light);
}

h3 {
  font-size: 1.5rem;
  margin-top: 2rem;
  color: var(--secondary);
  position: relative;
  overflow: hidden;
}

h3 i {
  margin-right: 10px;
  color: var(--primary-light);
  animation: pulse 2s infinite;
}

.calculator-container {
  background-color: var(--white);
  border-radius: var(--border-radius);
  padding: 2.5rem;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 900px;
  transition: var(--transition);
  border: 1px solid rgba(0, 0, 0, 0.05);
  position: relative;
  overflow: hidden;
}

.calculator-container::after {
  content: '';
  background-image: url('cal.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: 30% auto; /* Reduced from 50% to 30% */
  opacity: 0.03; /* Reduced from 0.05 to 0.03 for subtlety */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
  filter: grayscale(100%);
}

/* Ensure content appears above the watermark */
#solar-calculator, h3, .tariff-table, .note {
  position: relative;
  z-index: 1;
}

.calculator-container:hover {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

/* Enhanced decorative corners */
.decorative-corner {
  position: absolute;
  width: 80px;
  height: 80px;
  border: 4px solid var(--secondary);
  opacity: 0.15;
  z-index: 0;
  transition: all 0.5s ease;
}

.calculator-container:hover .decorative-corner {
  width: 100px;
  height: 100px;
  opacity: 0.25;
}

.decorative-corner.top-left {
  top: 20px;
  left: 20px;
  border-right: none;
  border-bottom: none;
}

.decorative-corner.bottom-right {
  bottom: 20px;
  right: 20px;
  border-left: none;
  border-top: none;
}

.form-group {
  margin-bottom: 1.8rem;
  position: relative;
  z-index: 1;
}

.form-group label {
  display: block;
  margin-bottom: 0.8rem;
  font-weight: 600;
  color: var(--primary);
  font-size: 1.1rem;
  transition: var(--transition);
}

.form-group label i {
  margin-right: 8px;
  color: var(--primary-light);
  width: 20px;
  text-align: center;
}

.form-group small {
  font-size: 0.85rem;
  color: #7f8c8d;
  font-weight: normal;
}

/* Enhanced input styling with icon space */
input.input-with-icon, select.input-with-icon {
  width: 100%;
  padding: 1rem 1.2rem 1rem 2.5rem;
  border: 2px solid var(--dark-gray);
  border-radius: var(--border-radius);
  font-size: 1rem;
  transition: var(--transition);
  background-color: var(--white);
  color: var(--text);
  appearance: none;
  position: relative;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
  transform: translateY(-2px);
}

/* Icon positioning for inputs */
.form-group label i {
  position: absolute;
  left: 12px;
  top: 40px;
  z-index: 2;
  color: var(--primary-light);
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%232c3e50' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 12px;
  padding-right: 2.5rem;
}

/* Enhanced button styling */
button {
  background-color: var(--primary-light);
  color: var(--white);
  border: none;
  padding: 1.2rem 2rem;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-size: 1.1rem;
  font-weight: 600;
  width: 100%;
  transition: var(--transition);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 0.5rem;
  box-shadow: 0 4px 6px rgba(52, 152, 219, 0.2);
  position: relative;
  overflow: hidden;
  z-index: 1;
}

button:hover {
  background-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(52, 152, 219, 0.3);
}

button:active {
  transform: translateY(0);
}

/* Button shine effect */
.btn-animate {
  position: relative;
  overflow: hidden;
}

.btn-shine {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(45deg);
  z-index: -1;
  transition: all 0.5s ease-in-out;
}

.btn-animate:hover .btn-shine {
  animation: shine 1.5s forwards;
}

@keyframes shine {
  0% {
    left: -50%;
    top: -50%;
  }
  100% {
    left: 150%;
    top: -50%;
  }
}

button i {
  margin-right: 8px;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.random-btn {
  width: auto;
  margin-top: 0.8rem;
  background-color: var(--secondary);
  font-size: 0.9rem;
  padding: 0.8rem 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: none;
  box-shadow: 0 4px 6px rgba(39, 174, 96, 0.2);
}

.random-btn:hover {
  background-color: #219955;
  box-shadow: 0 6px 12px rgba(39, 174, 96, 0.3);
}

.tariff-table {
  width: 100%;
  border-collapse: collapse;
  margin: 2rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border-radius: var(--border-radius);
  overflow: hidden;
  font-size: 0.95rem;
  transition: var(--transition);
  position: relative;
}

.tariff-table:hover {
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transform: translateY(-4px);
}

.tariff-table th,
.tariff-table td {
  border: 1px solid var(--dark-gray);
  padding: 1rem;
  text-align: left;
  transition: var(--transition);
  position: relative;
  z-index: 1;
}

.tariff-table th {
  background-color: var(--primary);
  color: var(--white);
  font-weight: 600;
  text-align: center;
}

.tariff-table tr:nth-child(even) {
  background-color: var(--gray);
}

.tariff-table tr:hover {
  background-color: #e3f2fd;
  transform: scale(1.01);
}

.tariff-table::before {
  content: '';
  background-image: url('cal.png');
  background-repeat: no-repeat;
  background-size: 50px auto;
  background-position: right bottom;
  opacity: 0.015;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
}

.note {
  font-size: 0.95rem;
  color: #7f8c8d;
  margin: 1.5rem 0;
  line-height: 1.6;
  padding: 1rem;
  background-color: #f8f9fa;
  border-left: 4px solid var(--secondary);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  transition: var(--transition);
  position: relative;
  background-image: linear-gradient(to right, rgba(255,255,255,0.95), rgba(255,255,255,0.98));
}

.note:hover {
  border-left-width: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  background-color: #f0f9f4;
}

.note strong {
  color: var(--primary);
}

.note i {
  margin-right: 5px;
  color: var(--secondary);
}

.results {
  margin-top: 2.5rem;
  background-color: var(--gray);
  padding: 2rem;
  border-radius: var(--border-radius);
  display: none;
  animation: fadeIn 0.6s ease-out forwards;
  border-left: 4px solid var(--primary-light);
}

.result-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px dashed var(--dark-gray);
  align-items: center;
  flex-wrap: wrap;
  transition: var(--transition);
  position: relative;
}

.result-item:hover {
  transform: translateX(5px);
}

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

.result-item::before {
  content: '';
  background-image: url('cal.png');
  background-repeat: no-repeat;
  background-size: 40px auto;
  background-position: right bottom;
  opacity: 0.02;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  pointer-events: none;
}

.result-label {
  font-weight: 600;
  color: var(--primary);
  font-size: 1.05rem;
  flex: 1;
  min-width: 200px;
}

.result-label i {
  margin-right: 8px;
  color: var(--primary-light);
}

.result-value {
  font-weight: 700;
  color: var(--primary);
  font-size: 1.1rem;
  text-align: right;
  flex: 1;
  transition: var(--transition);
}

.result-value:hover {
  transform: scale(1.05);
  color: var(--accent);
}

.highlight {
  color: var(--accent);
  font-weight: bold;
  background-color: rgba(231, 76, 60, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

/* Validation styles */
.form-group input.valid,
.form-group select.valid {
  border-color: var(--secondary);
  background-color: rgba(39, 174, 96, 0.05);
}

.form-group input.invalid,
.form-group select.invalid {
  border-color: var(--accent);
  background-color: rgba(231, 76, 60, 0.05);
}

.validation-errors {
  padding: 1rem;
  margin: 1rem 0;
  border-left: 4px solid var(--accent);
  background-color: rgba(231, 76, 60, 0.1);
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
  color: #c0392b;
  font-size: 0.95rem;
  animation: fadeIn 0.3s ease-in-out;
}

.validation-errors ul {
  margin: 0;
  padding-left: 1.5rem;
}

.validation-errors li {
  margin-bottom: 0.5rem;
}

.validation-errors li:last-child {
  margin-bottom: 0;
}

/* Shake animation for error messages */
.shake {
  animation: shake 0.82s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }
  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}

/* Focus style for inputs with validation */
.form-group input:focus.valid,
.form-group select:focus.valid {
  box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.2);
}

.form-group input:focus.invalid,
.form-group select:focus.invalid {
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.2);
}

/* Responsive improvements */
@media (max-width: 768px) {
  body {
    padding: 1rem 0.5rem;
  }
  
  h1 {
    font-size: 1.8rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .calculator-container {
    padding: 1.5rem 1rem;
    margin: 0 0.5rem;
    border-radius: 8px;
  }
  
  .tariff-table {
    font-size: 0.75rem;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }
  
  .tariff-table th,
  .tariff-table td {
    padding: 0.6rem 0.4rem;
  }
  
  .result-item {
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 0.8rem;
    margin-bottom: 0.8rem;
    gap: 0.25rem;
  }
  
  .result-value {
    text-align: left;
    width: 100%;
    font-size: 1rem;
  }
  
  .form-group {
    margin-bottom: 1.2rem;
  }
  
  input.input-with-icon, select.input-with-icon {
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
  
  button {
    padding: 1rem 1.5rem;
    font-size: 1rem;
  }
  
  .savings-methods {
    padding: 10px;
  }
  
  .savings-method {
    padding: 8px;
  }
  
  .method-formula {
    font-size: 12px;
  }
}

/* Additional mobile optimizations */
@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.3rem;
  }
  
  h3 {
    font-size: 1.2rem;
  }
  
  .logo-image {
    max-width: 80px;
  }
  
  .calculator-container {
    padding: 1.2rem 0.8rem;
    margin: 0;
    border-radius: 6px;
  }
  
  .decorative-corner {
    width: 50px;
    height: 50px;
  }
  
  .form-group label {
    font-size: 0.95rem;
  }
  
  .note {
    font-size: 0.85rem;
    padding: 0.8rem;
  }
  
  /* Increase touch target size */
  .form-group label i {
    font-size: 1.2rem;
  }
  
  /* Fix scrolling issues on mobile */
  html, body {
    overflow-x: hidden;
    position: relative;
    width: 100%;
  }
  
  /* Make table scrollable horizontally with indication */
  .tariff-table-container {
    position: relative;
    margin-bottom: 2rem;
  }
  
  .tariff-table-container::after {
    content: '← Scroll →';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    color: var(--dark-gray);
    animation: fadeInOut 2s infinite;
    opacity: 0.7;
    display: none;
  }
  
  @keyframes fadeInOut {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
  }
  
  /* Only show scroll indicator when table overflows */
  @media (max-width: 768px) {
    .tariff-table-container::after {
      display: block;
    }
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  input, select, button {
    min-height: 44px; /* Apple's recommended minimum touch target size */
  }
  
  .form-group {
    margin-bottom: 1.5rem; /* Increase spacing between form elements */
  }
  
  /* Increase spacing between table rows for touch */
  .tariff-table tr {
    line-height: 1.6;
  }
  
  /* Remove hover effects that don't work well on touch */
  .tariff-table tr:hover {
    transform: none;
    background-color: var(--gray);
  }
  
  /* Add indicator for scrollable tables */
  .table-scroll-container {
    position: relative;
  }
  
  /* Active states for touch feedback instead of hover */
  button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.2);
  }
}

/* Fixed positioned elements adjustment for mobile */
@media (max-width: 768px) {
  body::before {
    background-size: 40px 40px; /* Smaller pattern */
  }
}

/* iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
  /* Fix for iOS 100vh issue */
  body {
    min-height: -webkit-fill-available;
  }
  
  /* Prevent input zoom on iOS */
  input, select, textarea {
    font-size: 16px;
  }
}

/* Enhanced loader */
.loader {
  display: none;
  width: 48px;
  height: 48px;
  border: 5px solid var(--gray);
  border-bottom-color: var(--primary-light);
  border-radius: 50%;
  margin: 2rem auto;
  animation: loader-spin 1.5s linear infinite;
  position: relative;
}

.loader:before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 5px solid transparent;
  border-top-color: var(--secondary);
  animation: loader-spin 2s linear infinite;
}

@keyframes loader-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Enhanced pulse animation */
.pulse {
  animation: enhanced-pulse 2s infinite;
  display: inline-block;
}

@keyframes enhanced-pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
  100% { transform: scale(1); opacity: 1; }
}

/* Icon hover animations */
.form-group:hover label i {
  animation: rubberBand 1s;
}

@keyframes rubberBand {
  from { transform: scale3d(1, 1, 1); }
  30% { transform: scale3d(1.25, 0.75, 1); }
  40% { transform: scale3d(0.75, 1.25, 1); }
  50% { transform: scale3d(1.15, 0.85, 1); }
  65% { transform: scale3d(0.95, 1.05, 1); }
  75% { transform: scale3d(1.05, 0.95, 1); }
  to { transform: scale3d(1, 1, 1); }
}

/* Focus effect for form groups */
.form-group:focus-within label {
  color: var(--primary-light);
  transform: translateY(-2px);
}

/* Add a floating particle background */
.calculator-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 25% 25%, rgba(39, 174, 96, 0.03) 1%, transparent 5%),
    radial-gradient(circle at 75% 75%, rgba(52, 152, 219, 0.03) 1%, transparent 5%),
    radial-gradient(circle at 50% 50%, rgba(231, 76, 60, 0.03) 1%, transparent 10%);
  background-size: 50px 50px;
  opacity: 0.5;
  z-index: -1;
}

/* Hide form-group1 class */
.form-group1 {
  display: none;
}

/* Logo styling - updated to be smaller */
.logo-container {
  text-align: center;
  margin-bottom: 1rem;
}

.logo-image {
  max-width: 100px; /* Reduced from 150px to 100px */
  height: auto;
  animation: fadeIn 1.5s ease-in-out forwards, float 3s ease-in-out infinite;
}

@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-7px); } /* Reduced float animation height */
  100% { transform: translateY(0px); }
}

/* Savings methods styles */
.savings-methods {
  margin-top: 30px;
  padding: 15px;
  border-radius: 8px;
  background-color: #f8f9fa;
  border-left: 4px solid #27ae60;
}

.savings-methods h3 {
  margin-bottom: 15px;
  color: #2c3e50;
  font-size: 18px;
}

.savings-method {
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 6px;
  border: 1px solid #ddd;
  transition: all 0.3s ease;
}

.savings-method:last-child {
  margin-bottom: 0;
}

.active-method {
  border-color: #27ae60;
  background-color: rgba(39, 174, 96, 0.1);
  box-shadow: 0 2px 8px rgba(39, 174, 96, 0.2);
}

.method-title {
  font-weight: bold;
  margin-bottom: 5px;
  color: #333;
}

.method-formula {
  font-style: italic;
  color: #666;
  font-size: 14px;
  margin-bottom: 5px;
}

.method-value {
  font-weight: bold;
  color: #27ae60;
}