/* Reset y Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
  background-color: #f8f9fa;
  color: #333;
}

/* Container Principal */
.roll-calculator-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
}

.calculator-wrapper {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* Header */
.header {
  background: #214079;
  color: white;
  padding: 40px 30px;
  text-align: center;
}

.header h1 {
  margin: 0 0 10px 0;
  font-size: 2.5rem;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.header p {
  margin: 0;
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Form Container */
.form-container {
  padding: 30px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  margin-bottom: 30px;
}

/* Form Sections */
.form-section {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 25px;
  transition: all 0.3s ease;
}

.form-section:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-section.full-width {
  grid-column: 1 / -1;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
}

.section-icon {
  width: 28px;
  height: 28px;
  background: #214079;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
}

/* Form Elements */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #374151;
  font-size: 0.95rem;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
  font-family: inherit;
}

.form-input:focus {
  outline: none;
  border-color: #214079;
  box-shadow: 0 0 0 3px rgba(33, 64, 121, 0.1);
}

.form-input.is-invalid {
  border-color: #ef4444;
}

.unit-display {
  color: #6b7280;
  font-weight: 400;
  font-size: 0.9rem;
}

.info-text {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 5px;
  line-height: 1.4;
}

/* Unit Selector */
.unit-selector {
  display: flex;
  gap: 15px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.unit-option {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 12px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  transition: all 0.2s;
  flex: 1;
  min-width: 150px;
}

.unit-option:hover {
  border-color: #214079;
  background: #f8fafc;
}

.unit-option input[type="radio"] {
  margin-right: 8px;
  width: 18px;
  height: 18px;
}

.unit-option input[type="radio"]:checked + .unit-label {
  color: #214079;
  font-weight: 500;
}

.unit-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.unit-flag {
  font-size: 1.2rem;
}

/* Walls and Openings */
.wall-item, .opening-item {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  transition: box-shadow 0.2s;
}

.wall-item:hover, .opening-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.wall-header, .opening-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.wall-header h4, .opening-header h4 {
  margin: 0;
  color: #1e293b;
  font-size: 1.1rem;
}

.remove-wall-btn, .remove-opening-btn {
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 4px;
  width: 28px;
  height: 28px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.remove-wall-btn:hover, .remove-opening-btn:hover {
  background: #dc2626;
}

.wall-dimensions, .opening-dimensions {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 15px;
  align-items: start;
}

.wall-area-display, .opening-area-display {
  background: #f0f9ff;
  padding: 12px;
  border-radius: 6px;
  text-align: center;
  border: 1px solid #214079;
  margin-top: 1.7rem;
}

.wall-area, .opening-area {
  color: #214079;
  font-size: 1.1rem;
  font-weight: 600;
}

/* Add Buttons */
.add-wall-btn, .add-opening-btn {
  background: #10b981;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.add-wall-btn:hover, .add-opening-btn:hover {
  background: #059669;
}

.add-wall-btn:disabled, .add-opening-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}

/* Summaries */
.walls-summary, .openings-summary {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 15px;
  margin-top: 20px;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.summary-item:last-child {
  margin-bottom: 0;
  font-weight: 600;
  color: #1e293b;
}

/* Final Summary */
.final-summary {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border: 1px solid #214079;
  border-radius: 8px;
  padding: 25px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.summary-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.summary-card.highlight {
  background: #214079;
  color: white;
}

.summary-card.updated {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(33, 64, 121, 0.3);
}

.summary-label {
  font-size: 0.9rem;
  margin-bottom: 8px;
  opacity: 0.8;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Submit Button */
.submit-btn {
  background: #214079;
  color: white;
  border: none;
  padding: 16px 32px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 30px;
  font-family: inherit;
}

.submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(33, 64, 121, 0.3);
  background-color: #1a3260;
}

.submit-btn:disabled {
  background: #9ca3af;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Progress Bar */
.progress-container {
  margin: 20px 0;
  text-align: center;
  background: #f9fafb;
  border-radius: 12px;
  padding: 20px;
  border: 2px solid #e5e7eb;
}

.progress-bar {
  background: #e5e7eb;
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  background: #214079;
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
  animation: pulse 2s infinite;
}

.progress-text {
  text-align: center;
  margin-top: 10px;
  color: #374151;
  font-weight: 600;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Results Section */
.calculation-results {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  margin-top: 30px;
}

.results-header {
  text-align: center;
  margin-bottom: 30px;
}

.success-title {
  color: #059669;
  font-size: 2rem;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  font-weight: 700;
}

.success-icon {
  font-size: 2.5rem;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.result-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 25px;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.result-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.result-card.primary {
  background: #214079;
  color: white;
  border-color: #214079;
}

.result-icon {
  font-size: 2.5rem;
  margin-bottom: 15px;
}

.result-card.primary .result-icon {
  color: rgba(255, 255, 255, 0.9);
}

.result-info h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 10px;
  color: #374151;
}

.result-card.primary .result-info h4 {
  color: rgba(255, 255, 255, 0.9);
}

.result-value {
  font-size: 2rem;
  font-weight: 700;
  color: #214079;
  margin-bottom: 5px;
}

.result-card.primary .result-value {
  color: white;
}

.result-unit {
  font-size: 0.9rem;
  color: #6b7280;
  font-weight: 500;
}

.result-card.primary .result-unit {
  color: rgba(255, 255, 255, 0.8);
}

/* Breakdown */
.detailed-breakdown {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 30px;
}

.detailed-breakdown h3 {
  color: #374151;
  margin-bottom: 20px;
  font-size: 1.3rem;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #e5e7eb;
}

.breakdown-item:last-child {
  border-bottom: none;
}

.breakdown-item.total {
  font-weight: 600;
  color: #214079;
  border-top: 2px solid #214079;
  margin-top: 10px;
  padding-top: 15px;
}

/* Action Buttons */
.results-actions {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.action-btn {
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  border: 2px solid transparent;
  font-family: inherit;
}

.action-btn.primary {
  background: #214079;
  color: white;
  border-color: #214079;
}

.action-btn.primary:hover {
  background: #1a3260;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(33, 64, 121, 0.3);
}

.action-btn.secondary {
  background: #10b981;
  color: white;
  border-color: #10b981;
}

.action-btn.secondary:hover {
  background: #059669;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.3);
}

.action-btn.outline {
  background: transparent;
  color: #6b7280;
  border-color: #e5e7eb;
}

.action-btn.outline:hover {
  background: #f9fafb;
  border-color: #d1d5db;
  transform: translateY(-2px);
}

/* Product Search */
.product-search {
  position: relative;
  margin-bottom: 20px;
}

.roll-calculator-container .search-input {
  width: 100%;
  padding: 12px 16px 12px 45px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.3s ease;
  font-family: inherit;
}

.roll-calculator-container .search-input:focus {
  outline: none;
  border-color: #214079;
  box-shadow: 0 0 0 3px rgba(33, 64, 121, 0.1);
}

.search-icon {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 16px;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  margin-top: 5px;
}

.search-results.show {
  display: block;
}

.search-item {
  padding: 15px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 15px;
  transition: background-color 0.2s ease;
}

.search-item:hover {
  background: #f9fafb;
}

.search-item:last-child {
  border-bottom: none;
}

.search-item img {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 8px;
}

.search-item-info {
  flex: 1;
}

.search-item-info h6 {
  margin: 0 0 4px 0;
  color: #374151;
  font-weight: 600;
  font-size: 0.95rem;
}

.search-item-info p {
  margin: 0;
  color: #6b7280;
  font-size: 0.85rem;
}

.search-loading, .search-error, .search-no-results {
  padding: 20px;
  text-align: center;
  color: #6b7280;
  font-style: italic;
}

/* Selected Product */
.selected-product {
  background-color: #f0fdf4;
  border: 2px solid #10b981;
  border-radius: 16px;
  padding: 20px;
  margin-top: 20px;
}

.product-card {
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
}

.product-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 12px;
  border: 2px solid white;
  flex-shrink: 0;
}

.product-info {
  flex: 1;
}

.product-info h6 {
  margin: 0 0 8px 0;
  color: #374151;
  font-weight: 600;
  font-size: 1.1rem;
}

.product-info p {
  margin: 0 0 10px 0;
  color: #6b7280;
  font-size: 0.9rem;
}

.product-specs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.spec-item {
  background: rgba(255, 255, 255, 0.7);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
}

.spec-item strong {
  color: #374151;
  display: block;
}

.spec-item span {
  color: #6b7280;
}

.remove-btn {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
}

.remove-btn:hover {
  background: rgba(239, 68, 68, 1);
  transform: scale(1.1);
}

/* Checkbox Styling */
.checkbox-group {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 10px 0;
}

.checkbox-group input[type="checkbox"] {
  margin-right: 10px;
  width: 18px;
  height: 18px;
  accent-color: #214079;
}

/* Dimensions Grid */
.dimensions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

/* Loading Spinner */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-top: 2px solid transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  .roll-calculator-container {
    padding: 10px;
  }
  
  .form-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .calculator-wrapper {
    margin: 10px;
  }
  
  .form-container {
    padding: 20px;
  }
  
  .header {
    padding: 30px 20px;
  }
  
  .header h1 {
    font-size: 2rem;
  }
  
  .wall-dimensions, .opening-dimensions {
    grid-template-columns: 1fr;
  }
  
  .product-card {
    flex-direction: column;
    text-align: center;
  }
  
  .product-specs {
    grid-template-columns: 1fr;
  }
  
  .dimensions-grid {
    grid-template-columns: 1fr;
  }
  
  .options-grid {
    grid-template-columns: 1fr;
  }
  
  .unit-selector {
    flex-direction: column;
  }
  
  .unit-option {
    min-width: auto;
  }
  
  .results-grid {
    grid-template-columns: 1fr;
  }
  
  .summary-grid {
    grid-template-columns: 1fr;
  }
  
  .results-actions {
    flex-direction: column;
    align-items: center;
  }
  
  .action-btn {
    width: 100%;
    max-width: 300px;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .roll-calculator-container {
    padding: 1rem 0;
  }
  
  .form-section {
    padding: 20px;
  }
  
  .calculation-results {
    padding: 20px;
  }
  
  .success-title {
    font-size: 1.5rem;
    flex-direction: column;
    gap: 10px;
  }
  
  .header h1 {
    font-size: 1.8rem;
  }
  
  .header p {
    font-size: 1rem;
  }
}

/* Overlay bloqueador con loader */
#loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(33, 64, 121, 0.5);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

#loader-overlay .loader-spinner {
  width: 60px;
  height: 60px;
  border: 6px solid #ffffff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Modal */
.modal {
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(17, 24, 39, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-content {
  background-color: #ffffff;
  padding: 30px;
  border-radius: 12px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  right: 20px;
  top: 15px;
  font-size: 28px;
  color: #333;
  cursor: pointer;
}

.modal-close:hover {
  color: #dc2626;
}

.calculator-notes {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.warning-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 15px;
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    color: #856404;
}

.warning-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.help-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #e8f5e8;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    color: #155724;
}

.chat-icon {
    font-size: 20px;
}
.calculator-notes {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.warning-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 15px;
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    color: #856404;
}

.warning-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.help-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #e8f5e8;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    color: #155724;
}

.chat-icon {
    font-size: 20px;
}