:root {
    --primary: #9b6a4b; /* Elegant warm brown color */
    --primary-dark: #7a5137;
    --bg-color: #f7f8fa; /* Soft page background */
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #7f8c8d;
    --radius: 16px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Tajawal', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden; /* Prevent body scrolling, keep static UI */
}

/* --- Header Section --- */
.navbar {
    padding: 16px 24px;
    background: var(--card-bg);
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
    text-align: center;
    z-index: 10;
}

.navbar h1 {
    font-size: 22px;
    color: var(--primary);
    margin-bottom: 4px;
    font-weight: 700;
}

.navbar p {
    font-size: 14px;
    color: var(--text-muted);
}

/* --- Main Viewer Section --- */
.viewer-container {
    flex: 1;
    position: relative;
    width: 100%;
    /* Subtle gradient to simulate studio lighting */
    background: radial-gradient(circle at center, #ffffff 0%, #e0e5ec 100%);
}

model-viewer {
    width: 100%;
    height: 100%;
    --poster-color: transparent;
    outline: none;
}

/* AR Button */
.fab-ar-button {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 20px rgba(155, 106, 75, 0.4);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 20;
}

.fab-ar-button:hover, .fab-ar-button:active {
    box-shadow: 0 8px 25px rgba(155, 106, 75, 0.5);
    transform: translateX(-50%) translateY(-2px);
}

.fab-ar-button:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Loading state */
#loading-poster {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: inherit;
}
.spinner {
    width: 45px; height: 45px;
    border: 4px solid rgba(155, 106, 75, 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* --- Controls Drawer (Bottom Panel) --- */
.controls-drawer {
    background: var(--card-bg);
    padding: 24px 20px;
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.08);
    z-index: 10;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.control-group {
    margin-bottom: 24px;
}
.control-group:last-child {
    margin-bottom: 0;
}

.control-group h3 {
    font-size: 16px;
    margin-bottom: 14px;
    color: var(--text-main);
    font-weight: 700;
}

/* Size Buttons */
.options-row {
    display: flex;
    gap: 12px;
}

.option-btn {
    flex: 1;
    padding: 14px;
    background: var(--bg-color);
    border: 2px solid transparent;
    border-radius: var(--radius);
    color: var(--text-main);
    font-weight: 500;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.option-btn:hover {
    background: #eef0f4;
}

.option-btn.active {
    background: #fff;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(155, 106, 75, 0.15);
    font-weight: 700;
}

/* Texture Carousel Buttons */
.texture-options {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding: 4px; 
    padding-bottom: 8px; /* Room for shadow */
    scrollbar-width: none; /* Firefox */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}
.texture-options::-webkit-scrollbar {
    display: none; /* Safari/Chrome */
}

.texture-btn {
    flex: 0 0 85px;
    height: 85px;
    border-radius: var(--radius);
    border: 3px solid transparent;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    background: #eee;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.texture-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.texture-btn.active {
    border-color: var(--primary);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 6px 15px rgba(155, 106, 75, 0.3);
}
