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

@supports (-webkit-backdrop-filter: blur(10px)) {
    body {
        background-attachment: fixed;
    }
}

html {
    background: #1a202c;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    min-height: 100vh;
    padding: 1rem;
}

/* NEW: Add this wrapper around your entire app */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

/* NEW: Copper pipe header styling */
.copper-header {
    height: 4rem;
    border-radius: 0.5rem;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #d4a574 0%, #b8864a 50%, #d4a574 100%);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3), inset 0 -2px 4px rgba(255,255,255,0.2), 0 4px 12px rgba(0,0,0,0.4);
    margin-bottom: 2rem;
}

.copper-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(90deg, transparent, transparent 20px, rgba(0,0,0,0.1) 20px, rgba(0,0,0,0.1) 22px);
}

.copper-header h1 {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: #1a202c;
    letter-spacing: 0.05em;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
}

/* NEW: Header brackets */
.header-bracket {
    position: absolute;
    bottom: -0.25rem;
    width: 2rem;
    height: 0.5rem;
    background: #4a5568;
    border-radius: 0.125rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header-bracket.left {
    left: 1rem;
}

.header-bracket.right {
    right: 1rem;
}

/* NEW: Main content wrapper */
.content-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.controls {
    background: transparent;
    padding: 0;
    border-radius: 0;
    margin-bottom: 0;
    box-shadow: none;
}

.control-group {
    background: #374151;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
    margin-bottom: 1rem;
}

label {
    display: block;
    width: auto;
    color: #fdba74;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* NEW: Input display wrapper */
.input-display {
    background: #111827;
    border-radius: 0.5rem;
    padding: 1rem;
    position: relative;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}

input, select {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    font-size: 2rem;
    font-weight: bold;
    color: #4ade80;
    text-align: center;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
    padding: 0;
}

select {
    appearance: none;
    cursor: pointer;
}

/* NEW: Input unit labels */
.input-unit {
    position: absolute;
    bottom: 0.25rem;
    right: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
}

/* NEW: Select dropdown arrow */
.select-arrow {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #4ade80;
    filter: drop-shadow(0 0 5px rgba(74, 222, 128, 0.5));
    pointer-events: none;
}

button {
    width: 100%;
    border-radius: 0.75rem;
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
    border: none;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.125rem;
    letter-spacing: 0.025em;
    transition: all 0.2s;
    margin-right: 0;
    margin-bottom: 1rem;
}

button {
    background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4), inset 0 1px 2px rgba(255,255,255,0.2);
}

button.secondary {
    background: linear-gradient(180deg, #3b82f6 0%, #1e40af 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4), inset 0 1px 2px rgba(255,255,255,0.2);
}

button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    opacity: 0.2;
    transition: opacity 0.2s;
}

button:hover::before {
    opacity: 0.3;
}

button:hover {
    background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
}

button.secondary:hover {
    background: linear-gradient(180deg, #3b82f6 0%, #1e40af 100%);
}

button:active {
    transform: translateY(2px);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}


/* PDF Download button  */
button.pdf {
    background: linear-gradient(180deg, #10b981 0%, #047857 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4), inset 0 1px 2px rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

button.pdf:hover {
    background: linear-gradient(180deg, #10b981 0%, #047857 100%);
}

/* PDF icon SVG styling */
.pdf-icon {
    width: 1.25rem;
    height: 1.25rem;
}


#canvas-container {
    background: #374151;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
    text-align: center;
}

/* NEW: Preview label */
.preview-label {
    color: #fdba74;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    text-align: left;
}

canvas {
    border: none;
    max-width: 100%;
    background: #111827;
    border-radius: 0.5rem;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.5);
}

.legend {
    margin-top: 15px;
    text-align: left;
    display: inline-block;
    color: #9ca3af;
    font-size: 0.875rem;
}

.legend-item {
    margin: 5px 0;
}

.legend-color {
    display: inline-block;
    width: 30px;
    height: 3px;
    margin-right: 10px;
    vertical-align: middle;
}

.summary {
    margin-top: 1rem;
    padding: 1rem;
    background: #1f2937;
    border-radius: 0.5rem;
    text-align: left;
    color: #9ca3af;
    font-size: 0.875rem;
}

.summary h3 {
    margin-top: 0;
    color: #fdba74;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.summary p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

.zone-info {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: #374151;
    border-left: 3px solid #f97316;
    border-radius: 0.25rem;
}

.zone-info h4 {
    margin: 5px 0;
    font-size: 0.75rem;
    color: #f97316;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.zone-info p {
    font-size: 0.75rem;
    margin: 0.125rem 0;
}

.warning {
    color: #ef4444;
    font-weight: bold;
}

/* Bill of Materials section */
.bom-container {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #1f2937;
    border-radius: 0.5rem;
    border: 1px solid #374151;
}

.bom-title {
    color: #fdba74;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
}

.bom-content {
    color: #9ca3af;
    font-size: 0.875rem;
}

.bom-placeholder {
    color: #6b7280;
    font-style: italic;
    margin: 0;
}

.bom-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #374151;
}

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

.bom-item-name {
    color: #e5e7eb;
    font-weight: 500;
}

.bom-item-qty {
    color: #4ade80;
    font-weight: 600;
}

.bom-item-detail {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 0.25rem;
}

.bom-category {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 2px solid #374151;
}

.bom-category:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.bom-category-title {
    color: #f97316;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    letter-spacing: 0.05em;
}

.bom-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #374151;
}

.bom-toggle {
    width: 100%;
    background: transparent;
    border: 1px solid #4ade80;
    color: #4ade80;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
    margin-bottom: 0;
}

.bom-toggle:hover {
    background: rgba(74, 222, 128, 0.1);
    border-color: #4ade80;
}

.bom-toggle:active {
    transform: translateY(1px);
}

.toggle-icon {
    width: 1rem;
    height: 1rem;
    transition: transform 0.3s;
}

.toggle-icon.rotated {
    transform: rotate(180deg);
}

.bom-details {
    display: none;
    margin-top: 0.75rem;
}

.bom-details.visible {
    display: block;
}
/* bom prices */
/* BOM pricing columns */
.bom-item {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 1rem;
    align-items: start;
    padding: 0.5rem 0;
    border-bottom: 1px solid #374151;
}

.bom-item-info {
    min-width: 0;
}

.bom-item-qty,
.bom-item-cost,
.bom-item-total {
    text-align: right;
    white-space: nowrap;
}

.bom-item-cost {
    color: #9ca3af;
    font-size: 0.875rem;
}

.bom-item-total {
    color: #fbbf24;
    font-weight: 600;
    min-width: 80px;
}

/* BOM header row */
.bom-header {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 2px solid #4ade80;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #4ade80;
    text-transform: uppercase;
}

.bom-header-item {
    text-align: right;
}

.bom-header-item:first-child {
    text-align: left;
}

/* Grand total section */
.bom-grand-total {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 2px solid #4ade80;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bom-total-label {
    color: #fdba74;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
}

.bom-total-amount {
    color: #4ade80;
    font-size: 1.5rem;
    font-weight: 700;
    text-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

.bom-total-currency {
    font-size: 1rem;
    margin-left: 0.25rem;
}

/* Category subtotal */
.bom-category-subtotal {
    display: flex;
    justify-content: flex-end;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #e5e7eb;
}

.bom-subtotal-label {
    margin-right: 1rem;
    color: #9ca3af;
}

.bom-subtotal-amount {
    color: #fbbf24;
    font-weight: 600;
    min-width: 80px;
    text-align: right;
}

/* Currency selector */
.bom-currency-selector {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.bom-currency-selector label {
    color: #9ca3af;
    margin: 0;
    font-size: 0.75rem;
}

.bom-currency-selector select {
    background: #374151;
    border: 1px solid #4ade80;
    color: #4ade80;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    width: auto;
    text-align: left;
}

/* Responsive layout for tablet and desktop */
@media (min-width: 768px) {
    .app-container {
        max-width: 1200px;
        padding: 2rem;
    }

    .copper-header {
        height: 5rem;
        margin-bottom: 2rem;
    }

    .copper-header h1 {
        font-size: 2.5rem;
    }

    .header-bracket {
        width: 3rem;
        height: 0.75rem;
    }

    .header-bracket.left {
        left: 2rem;
    }

    .header-bracket.right {
        right: 2rem;
    }

    .content-area {
        flex-direction: row;
        gap: 1.5rem;
    }

    .preview-section {
        flex: 1;
    }

    .controls-section {
        width: 24rem;
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    #canvas-container {
        height: 100%;
    }
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 1400px;
    }

    .controls-section {
        width: 28rem;
    }
}

@media print {
  .no-print { display: none; }
  .print-only { display: block; }
}
