@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #0f172a;
    --primary-hover: #1e293b;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --font-family: 'Outfit', sans-serif;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-md: 0.75rem;
    --radius-lg: 1.25rem;
    --radius-xl: 2rem;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-main);
}

p {
    color: var(--text-muted);
}

a {
    text-decoration: none;
    color: inherit;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

/* Layout Utilities */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.gap-8 {
    gap: 2rem;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-accent {
    background: var(--accent-gradient);
    color: white;
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    border-color: var(--text-main);
}

.btn-block {
    width: 100%;
}

/* Hero Section */
.hero {
    padding: 6rem 0;
    text-align: center;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
}

.hero p {
    font-size: 1.25rem;
    max-width: 600px;
    margin: 0 auto 2.5rem;
}

/* Pricing Section */
.pricing {
    padding: 4rem 0 8rem;
}

.pricing-header {
    text-align: center;
    margin-bottom: 4rem;
}

.pricing-header h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    align-items: start;
}

.pricing-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.pricing-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.pricing-card.popular {
    border: 2px solid var(--accent);
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.pricing-card.popular:hover {
    transform: scale(1.05) translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.popular-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-gradient);
    color: white;
    padding: 0.25rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
}

.price {
    font-size: 3rem;
    font-weight: 700;
    margin: 1.5rem 0;
    color: var(--text-main);
}

.price span {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
}

.features-list {
    list-style: none;
    margin: 2rem 0;
    flex-grow: 1;
}

.features-list li {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.features-list li svg {
    margin-right: 0.75rem;
    color: var(--success);
    flex-shrink: 0;
}

/* App Interface */
.app-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    padding: 2rem 0;
    min-height: calc(100vh - 80px);
}

.app-sidebar {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    height: fit-content;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.preset-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-item:hover,
.preset-item.active {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.preset-item svg {
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.preset-item.active svg {
    color: var(--accent);
}

.app-main {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-toolbar {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.layout-viewer {
    flex-grow: 1;
    background: #F3F4F6;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
}

.blueprint-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-size: 40px 40px;
    background-image:
        linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
}

/* Locked Feature UI */
.locked-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    text-align: center;
    padding: 2rem;
}

.locked-overlay svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.locked-overlay h3 {
    margin-bottom: 0.5rem;
}

/* Success Page */
.success-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 70vh;
    text-align: center;
}

.success-icon {
    width: 80px;
    height: 80px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
}

.success-icon svg {
    width: 40px;
    height: 40px;
}

.success-page h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.success-page p {
    font-size: 1.125rem;
    max-width: 500px;
    margin-bottom: 2rem;
}

/* Layout Variations Grid (for App) */
.variations-container {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid var(--border-color);
}

.variations-grid {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.variation-thumb {
    width: 120px;
    height: 80px;
    background: #F3F4F6;
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.variation-thumb.active {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 2.5rem;
    }

    .pricing-card.popular {
        transform: none;
    }

    .pricing-card.popular:hover {
        transform: translateY(-5px);
    }
}

/* Realistic 2D Furniture */
.draggable-furniture {
    position: relative;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    cursor: grab;
    margin: 4px;
    user-select: none;
    touch-action: none;
    /* For mobile dragging */
    resize: both;
    overflow: hidden;
    cursor: grab;
}

/* Ensure clicking text/labels doesn't block dragging */
.draggable-furniture > span, 
.draggable-furniture > small,
.draggable-furniture > br,
.room-dims,
.room-handle span {
    pointer-events: none;
}

.draggable-room {
    cursor: grab;
}

.draggable-room:active,
.draggable-furniture:active {
    cursor: grabbing;
}

.draggable-furniture.dragging {
    cursor: grabbing;
    z-index: 1000;
    opacity: 0.9;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.3);
}

.draggable-furniture:hover:not(.dragging) {
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

/* Bedrooms */
.f-bed {
    width: 50px;
    height: 70px;
    background: #e2e8f0;
    border-top: 15px solid #cbd5e1;
    border-radius: 4px;
    border: 1px solid #94a3b8;
}

.f-wardrobe {
    width: 70px;
    height: 30px;
    background: #8B4513;
    border-bottom: 2px solid #5c2e0b;
    border-radius: 2px;
}

.f-nightstand {
    width: 25px;
    height: 25px;
    background: #D2B48C;
    border-radius: 2px;
    border: 1px solid #a6845e;
}

.f-desk {
    width: 45px;
    height: 30px;
    background: #A0522D;
    border-radius: 2px;
    border-bottom: 3px solid #5D2E14;
    position: relative;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.1);
}

/* Living Room */
.f-sofa {
    width: 90px;
    height: 45px;
    background: #334155;
    border-radius: 8px 8px 0 0;
    border: 3px solid #1e293b;
    border-bottom: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: all 0.2s ease;
}

/* Smart Hiding for small elements */
.drop-zone .room-handle,
.draggable-furniture {
    transition: font-size 0.2s, opacity 0.2s;
}

/* Removed dimension hiding to ensure visibility */
/*
@container (max-width: 40px) or (max-height: 30px) {
    .room-dims,
    .furn-dims {
        display: none;
    }
}
*/

/* Fallback for browsers without container queries */
.drop-zone,
.draggable-furniture {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}


.f-tv {
    width: 70px;
    height: 15px;
    background: #0f172a;
    border-radius: 2px;
    color: #fff;
    font-size: 0.55rem;
}

.f-dining {
    width: 70px;
    height: 50px;
    background: #d97706;
    border-radius: 10px;
    border: 2px solid #b45309;
}

/* Bathrooms */
.f-toilet {
    width: 25px;
    height: 35px;
    background: #fff;
    border-radius: 10px 10px 20px 20px;
    border: 1px solid #cbd5e1;
    color: #333;
    text-shadow: none;
    font-size: 0.55rem;
}

.f-shower {
    width: 45px;
    height: 45px;
    background: #e0f2fe;
    border: 2px solid #7dd3fc;
    border-radius: 4px;
    color: #0284c7;
    text-shadow: none;
    font-size: 0.55rem;
}

.f-sink {
    width: 35px;
    height: 25px;
    background: #f8fafc;
    border-radius: 20px;
    border: 1px solid #cbd5e1;
    color: #333;
    text-shadow: none;
    font-size: 0.55rem;
}

/* Kitchen */
.f-fridge {
    width: 35px;
    height: 35px;
    background: #cbd5e1;
    border-radius: 2px;
    border: 2px solid #94a3b8;
    color: #333;
    text-shadow: none;
    font-size: 0.55rem;
}

.f-stove {
    width: 35px;
    height: 35px;
    background: #1e293b;
    border-radius: 2px;
    position: relative;
    font-size: 0.55rem;
}

.f-washer {
    width: 35px;
    height: 35px;
    background: #fff;
    border-radius: 2px;
    border: 2px solid #e2e8f0;
    color: #333;
    text-shadow: none;
    font-size: 0.55rem;
}

.f-kitchen-sink {
    width: 45px;
    height: 30px;
    background: #f1f5f9;
    border-radius: 4px;
    border: 2px solid #94a3b8;
    color: #333;
    text-shadow: none;
    font-size: 0.55rem;
}

/* Unified Resizing System */
.drop-zone.resizing,
.draggable-furniture.resizing {
    box-shadow: 0 0 0 3px var(--accent), var(--shadow-xl) !important;
    z-index: 2000 !important;
    outline: none;
    transition: none !important;
}

.resize-handle {
    position: absolute;
    background: white;
    border: 2px solid var(--accent);
    border-radius: 50%;
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
    pointer-events: auto;
}

.room-handle-style {
    width: 16px;
    height: 16px;
    background: #ffffff;
    border: 3px solid var(--accent);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    cursor: crosshair;
}

.room-handle-style:hover {
    background: var(--accent);
    transform: scale(1.3);
}

.furn-handle-style {
    width: 8px;
    height: 8px;
    border-width: 1.5px;
    border-color: #6366f1;
    /* Indigo for furniture */
}

.drop-zone:hover .resize-handle,
.draggable-furniture:hover .resize-handle {
    opacity: 1;
}

.resize-handle:hover {
    transform: scale(1.4);
    background: var(--accent);
}

.furn-handle-style:hover {
    background: #6366f1;
}

/* Rotation Handle */
.rotation-handle {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 2px solid #10b981;
    /* Green for rotation */
    border-radius: 50%;
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
    cursor: crosshair;
}

.rotation-handle::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    width: 2px;
    height: 15px;
    background: #10b981;
    transform: translateX(-50%);
}

.drop-zone:hover .rotation-handle,
.draggable-furniture:hover .rotation-handle {
    opacity: 1;
}

.rotation-handle:hover {
    background: #10b981;
    transform: translateX(-50%) scale(1.2);
}

.drop-zone,
.draggable-furniture {
    transform-origin: center center;
}

/* Delete Button Style */
.element-delete-btn {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1300;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1;
}

.drop-zone:hover .element-delete-btn,
.draggable-furniture:hover .element-delete-btn {
    opacity: 1;
}

.element-delete-btn:hover {
    background: #dc2626;
    transform: scale(1.2);
}

/* Duplicate Button Style */
.element-dupe-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #22c55e;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1300;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s, background 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    line-height: 1;
}

.drop-zone:hover .element-dupe-btn,
.draggable-furniture:hover .element-dupe-btn {
    opacity: 1;
}

.element-dupe-btn:hover {
    background: #16a34a;
    transform: scale(1.2);
}

/* Handle Positions (Unified) */
.handle-n {
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.handle-s {
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
}

.handle-e {
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: ew-resize;
}

.handle-w {
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: ew-resize;
}

.handle-nw {
    top: -6px;
    left: -6px;
    cursor: nwse-resize;
}

.handle-ne {
    top: -6px;
    right: -6px;
    cursor: nesw-resize;
}

.handle-sw {
    bottom: -6px;
    left: -6px;
    cursor: nesw-resize;
}

.handle-se {
    bottom: -6px;
    right: -6px;
    cursor: nwse-resize;
}

/* Adjust positions for smaller furniture handles */
.draggable-furniture .handle-n {
    top: -4px;
}

.draggable-furniture .handle-s {
    bottom: -4px;
}

.draggable-furniture .handle-e {
    right: -4px;
}

.draggable-furniture .handle-w {
    left: -4px;
}

.draggable-furniture .handle-nw {
    top: -4px;
    left: -4px;
}

.draggable-furniture .handle-ne {
    top: -4px;
    right: -4px;
}

.draggable-furniture .handle-sw {
    bottom: -4px;
    left: -4px;
}

.draggable-furniture .handle-se {
    bottom: -4px;
    right: -4px;
}

/* Resize Tooltip */
.resize-tooltip {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(17, 24, 39, 0.9);
    color: white;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1200;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.drop-zone.resizing .resize-tooltip,
.draggable-furniture.resizing .resize-tooltip {
    opacity: 1;
}

/* Print Styles */
@media print {

    header,
    .app-sidebar,
    .variations-container,
    .btn,
    .element-delete-btn,
    .element-dupe-btn,
    .resize-handle,
    .rotation-handle,
    .app-toolbar {
        display: none !important;
    }

    body {
        background: white;
    }

    .app-container {
        display: block;
        padding: 0;
    }

    .app-main {
        border: none;
        box-shadow: none;
    }

    .layout-viewer {
        background: white;
        min-height: auto;
        padding: 2rem;
    }

    #layout-grid-container {
        border: 2px solid #000 !important;
        box-shadow: none !important;
    }

    .drop-zone {
        border: 1px solid #000 !important;
    }

    #space-report-container {
        display: block !important;
        margin-top: 2rem;
        page-break-inside: avoid;
    }

    .logo {
        -webkit-text-fill-color: black !important;
        color: black !important;
        margin-bottom: 2rem;
    }
}