/**
 * Fabric Calculator Styles
 * Matches Quiltler 3 design system
 */

/* ============================================================================
   MODAL OVERLAY
   ============================================================================ */

.calculator-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    overflow-y: auto;
    backdrop-filter: blur(4px);
}

.calculator-modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ============================================================================
   MODAL CONTENT CONTAINER
   ============================================================================ */

.calculator-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================================
   CLOSE BUTTON
   ============================================================================ */

.calculator-close {
    position: sticky;
    top: 0;
    right: 0;
    width: 100%;
    display: flex;
    justify-content: flex-end;
    padding: 20px 20px 0 20px;
    background: white;
    z-index: 10;
}

.calculator-close button {
    background: #f5f5f5;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #333;
    font-size: 24px;
    line-height: 1;
}

.calculator-close button:hover {
    background: #e0e0e0;
    transform: scale(1.1);
}

/* ============================================================================
   CALCULATOR CONTENT
   ============================================================================ */

#calculator-content {
    padding: 0 30px 30px 30px;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top: 4px solid #7B68EE;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading p {
    color: #666;
    font-size: 16px;
}

/* ============================================================================
   ERROR STATE
   ============================================================================ */

.error {
    text-align: center;
    padding: 40px 20px;
}

.error h3 {
    color: #d32f2f;
    margin-bottom: 10px;
}

.error p {
    color: #666;
    margin-bottom: 20px;
}

/* ============================================================================
   RESULTS LAYOUT
   ============================================================================ */

.calculator-results {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Header */
.calc-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.calc-header h2 {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 5px 0;
}

.calc-subtitle {
    font-size: 16px;
    color: #7B68EE;
    margin: 0;
    font-weight: 600;
}

/* ============================================================================
   QUILT IMAGE SECTION
   ============================================================================ */

.quilt-image-section {
    margin: 25px 0;
    text-align: center;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
}

.quilt-preview-image {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: block;
    margin: 0 auto;
}

/* Sections */
.calc-section {
    margin-bottom: 30px;
}

.calc-section h3 {
    font-size: 20px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #7B68EE;
}

/* ============================================================================
   DIMENSIONS
   ============================================================================ */

.dimension-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.dimension-label {
    font-weight: 600;
    color: #555;
}

.dimension-value {
    font-size: 18px;
    font-weight: 700;
    color: #2c3e50;
}

/* ============================================================================
   FABRIC LIST
   ============================================================================ */

.fabric-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Fabric Group - contains main fabric + variations */
.fabric-group {
  border-radius: 12px;
  border: 2px solid #e0e0e0;
  overflow: hidden;
}

/* Main fabric header */
.fabric-main {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px;
  background: white;
  border-bottom: 2px solid #f0f0f0;
}

.fabric-swatch {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.fabric-details {
  flex: 1;
  min-width: 0;
}

.fabric-name {
  font-weight: 700;
  color: #2c3e50;
  font-size: 17px;
  margin-bottom: 4px;
}

.fabric-usage {
  font-size: 13px;
  color: #666;
}

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

.total-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #888;
  margin-bottom: 4px;
}

.fabric-yardage {
  font-size: 20px;
  font-weight: 700;
  color: #7B68EE;
  white-space: nowrap;
}

/* Fabric Variations (Cutting Instructions) */
.fabric-variations {
  background: #fafafa;
  display: flex;
  flex-direction: column;
}

.variation-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 14px 16px;
  background: white;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.2s ease;
}

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

.variation-item:hover {
  background: #f8f9fa;
}

.variation-swatch-canvas {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  background: #f5f5f5;
}

.variation-swatch {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.variation-details {
  flex: 1;
  min-width: 0;
}

.variation-cut-name {
  font-weight: 600;
  color: #7B68EE;
  font-size: 14px;
  margin-bottom: 4px;
}

.variation-stats {
  font-size: 12px;
  color: #666;
}

.variation-yardage {
  font-size: 16px;
  font-weight: 700;
  color: #2c3e50;
  white-space: nowrap;
}

/* ============================================================================
   SPECIAL REQUIREMENTS (Batting, Backing, Binding)
   ============================================================================ */

.special-requirement {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
}

.special-requirement:last-child {
    margin-bottom: 0;
}

.req-label {
    font-weight: 600;
    color: #555;
}

.req-value {
    font-weight: 700;
    color: #2c3e50;
    text-align: right;
}

/* ============================================================================
   ACTIONS
   ============================================================================ */

.calc-actions {
    margin: 30px 0;
    text-align: center;
}

.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 28px;
    background: linear-gradient(135deg, #7B68EE 0%, #9B8FFF 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(123, 104, 238, 0.3);
}

.btn-export:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 104, 238, 0.4);
}

.btn-export:active {
    transform: translateY(0);
}

.btn-export:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-export:disabled:hover {
    background: #ccc;
    transform: none;
    box-shadow: 0 4px 12px rgba(123, 104, 238, 0.2);
}

/* Loading spinner animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    animation: spin 1s linear infinite;
}

.btn-primary {
    padding: 12px 24px;
    background: #7B68EE;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: #6A5ACD;
}

/* ============================================================================
   CALCULATION NOTES
   ============================================================================ */

.calc-notes {
    margin-top: 30px;
    padding: 20px;
    background: #f0f4ff;
    border-radius: 8px;
    border-left: 4px solid #7B68EE;
}

.calc-notes p {
    margin: 0 0 10px 0;
    color: #555;
    font-size: 14px;
}

.calc-notes ul {
    margin: 0;
    padding-left: 20px;
    color: #666;
    font-size: 13px;
}

.calc-notes li {
    margin-bottom: 5px;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
    .calculator-modal.show {
        padding: 0;
        align-items: flex-start;
    }
    
    .calculator-modal-content {
        border-radius: 0;
        max-height: 100vh;
        min-height: 100vh;
    }
    
    #calculator-content {
        padding: 0 20px 20px 20px;
    }
    
    .calc-header h2 {
        font-size: 24px;
    }
    
    .fabric-item {
        padding: 12px;
        gap: 12px;
    }
    
    .fabric-swatch {
        width: 35px;
        height: 35px;
    }
    
    .fabric-name {
        font-size: 15px;
    }
    
    .fabric-yardage {
        font-size: 16px;
    }
    
    .dimension-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .special-requirement {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
  .req-value {
    text-align: left;
  }
  
  .fabric-main {
    flex-wrap: wrap;
  }
  
  .fabric-total {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
  }
  
  .variation-item {
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .variation-yardage {
    width: 100%;
    text-align: right;
  }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  /* Hide buttons and overlay */
  .close-btn,
  .calc-actions,
  .calculator-close {
    display: none !important;
  }
  
  /* Make modal print-friendly */
  .calculator-modal {
    background: white !important;
  }
  
  .calculator-container,
  .calculator-modal-content {
    box-shadow: none !important;
    max-height: none !important;
  }
  
  /* Page break control */
  .calc-section,
  .fabric-group,
  .variation-item,
  .special-requirement {
    page-break-inside: avoid;
  }
  
  /* Ensure colors print */
  canvas,
  img,
  .fabric-swatch,
  .variation-swatch,
  .variation-swatch-canvas {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
}

@media (max-width: 480px) {
    .calc-header h2 {
        font-size: 20px;
    }
    
    .calc-section h3 {
        font-size: 18px;
    }
    
    .fabric-item:hover {
        transform: none;
    }
}

/* ============================================================================
   SCROLLBAR STYLING
   ============================================================================ */

.calculator-modal-content::-webkit-scrollbar {
    width: 8px;
}

.calculator-modal-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 16px 16px 0;
}

.calculator-modal-content::-webkit-scrollbar-thumb {
    background: #7B68EE;
    border-radius: 4px;
}

.calculator-modal-content::-webkit-scrollbar-thumb:hover {
    background: #6A5ACD;
}

