/* Design Page Styles - COMPLETELY FIXED VERSION */

/* ── Header ──────────────────────────────────────────────────────────────── */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    z-index: 1000;
}

.header-container {
    max-width: 100%;
    height: 100%;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

/* Logo text */
.logo-text {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
}

/* Nav links */
.main-nav {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.main-nav a {
    text-decoration: none;
    color: #4a5568;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.main-nav a:hover {
    background: #f0fdf4;
    color: #059669;
}

.main-nav a.active {
    background: #d1fae5;
    color: #065f46;
    font-weight: 600;
}

/* Right-side actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.upload-photo-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 0.5rem 1.1rem;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.upload-photo-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35);
}

.user-badge {
    background: #f0fdf4;
    color: #065f46;
    border: 1.5px solid #a7f3d0;
    padding: 0.4rem 0.9rem;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

/* ── Body allows normal scrolling ──────────────────────────────────────────── */
body {
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
}

.nav-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.save-btn {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s;
}

.save-btn:hover {
    transform: translateY(-2px);
}

.clear-btn {
    background: #ef4444;
    color: white;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.3s;
}

.clear-btn:hover {
    transform: translateY(-2px);
}

/* FIXED: Design Section allows normal scroll */
.design-section {
    min-height: calc(100vh - 64px);
    margin-top: 64px;
    background: #f9fafb;
    padding-bottom: 2rem;
}

.design-container {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    min-height: calc(100vh - 80px);
    gap: 0;
}

/* FIXED: Sidebar is sticky and scrollable */
.design-sidebar {
    background: white;
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid #e5e7eb;
    max-height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
}

.design-sidebar h3 {
    color: #065f46;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.tool-category {
    margin-bottom: 0.5rem;
}

.category-btn {
    width: 100%;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 2px solid #10b981;
    padding: 1rem;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    color: #065f46;
    transition: all 0.3s;
}

.category-btn:hover {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
    transform: translateX(5px);
}

.category-btn.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.category-icon {
    font-size: 1.5rem;
}

.arrow {
    font-size: 1.5rem;
    transition: transform 0.3s;
}

.category-btn.active .arrow {
    transform: rotate(90deg);
}

.category-options {
    padding: 0.5rem 0 0 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-btn {
    background: white;
    border: 2px solid #e5e7eb;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.option-btn:hover {
    border-color: #10b981;
    background: #f0fdf4;
    transform: translateX(5px);
}

.option-btn:active {
    transform: scale(0.95);
}

.instructions {
    margin-top: 2rem;
    padding: 1rem;
    background: #fffbeb;
    border: 2px solid #fbbf24;
    border-radius: 12px;
}

.instructions h4 {
    color: #92400e;
    margin-bottom: 0.75rem;
}

.instructions ul {
    list-style: none;
    padding: 0;
}

.instructions li {
    color: #78350f;
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

/* CRITICAL FIX: Canvas stays fixed in viewport */
.design-canvas {
    position: sticky !important;
    top: 64px !important;
    height: calc(100vh - 64px) !important;
    background: #e5e7eb;
    overflow: hidden !important;
}

/* CRITICAL FIX: Image fills canvas but doesn't scroll */
#canvasImage {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    display: block;
}

.canvas-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 2rem 3rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    pointer-events: none;
    z-index: 10;
}

.canvas-hint p {
    color: #6b7280;
    font-size: 1.2rem;
    margin: 0;
}

/* FIXED: Draggable items positioned correctly */
.draggable-item {
    position: absolute !important;
    cursor: move;
    user-select: none;
    font-size: 48px;
    transition: transform 0.1s;
    z-index: 20 !important;
}

.draggable-item:hover {
    filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.5));
}

.draggable-item.selected {
    filter: drop-shadow(0 0 15px rgba(16, 185, 129, 1));
}

/* Control Panel for Selected Item */
.control-panel {
    position: absolute;
    background: white;
    border: 2px solid #10b981;
    border-radius: 12px;
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    z-index: 100;
}

.control-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #f0fdf4;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: #10b981;
    transform: scale(1.1);
}

.control-btn.delete {
    background: #fee2e2;
}

.control-btn.delete:hover {
    background: #ef4444;
}

/* FIXED: Materials Panel is sticky and scrollable */
.materials-panel {
    background: white;
    padding: 1.5rem;
    overflow-y: auto;
    border-left: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 64px);
    position: sticky;
    top: 64px;
}

.materials-panel h3 {
    color: #065f46;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.materials-list {
    flex: 1;
    overflow-y: auto;
}

.empty-message {
    color: #9ca3af;
    text-align: center;
    padding: 2rem 1rem;
    font-style: italic;
}

.material-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 1rem;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.material-item.coverage-item {
    background: #f0fdf4;
    border-color: #6ee7b7;
}

.material-info {
    flex: 1;
}

.material-name {
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.25rem;
}

.material-quantity {
    font-size: 0.85rem;
    color: #6b7280;
}

.material-price {
    font-weight: 700;
    color: #10b981;
    font-size: 1.1rem;
}

.total-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e5e7eb;
}

.total-cost {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.total-cost span:first-child {
    color: #374151;
}

.total-cost span:last-child {
    color: #10b981;
}

/* FIXED: Checkout button styling */
.checkout-main-btn {
    width: 100%;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 1rem;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.checkout-main-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
}

.checkout-main-btn:active {
    transform: translateY(-1px);
}

/* Category items scroll */
.category-items {
    max-height: 400px;
    overflow-y: auto;
}

/* Product items in sidebar */
.category-section {
    margin-bottom: 1rem;
}

.product-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0.5rem;
}

.product-item:hover {
    border-color: #10b981;
    background: #f0fdf4;
    transform: translateX(5px);
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    color: #374151;
    font-size: 0.9rem;
}

.product-price {
    color: #10b981;
    font-weight: 700;
    font-size: 0.85rem;
}

.expand-icon {
    font-size: 1rem;
    transition: transform 0.2s;
}

/* Responsive */
@media (max-width: 1024px) {
    .design-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .design-sidebar,
    .materials-panel {
        max-height: 300px;
        position: relative;
        top: 0;
    }
    
    .design-canvas {
        position: relative !important;
        top: 0 !important;
        height: 600px !important;
    }
}