/* Minimal Black & White Theme - Mobile-first with Visible Tools */

/* Base reset */
* { box-sizing: border-box; }
html,body{height:100%;margin:0;background:#fff;color:#111;font-family:Roboto,system-ui,-apple-system,Segoe UI,Arial;}

/* Main layout */
.fpd-app{min-height:100vh;display:flex;flex-direction:column;}

/* Top bar */
.fpd-topbar{
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:10px 14px;
    border-bottom:2px solid #111;
    background:#fff;
    position:sticky;
    top:0;
    z-index:40;
    flex-wrap: wrap;
    gap: 10px;
}
.tb-left,.tb-center,.tb-right{display:flex;align-items:center;gap:10px;}
.tb-center{flex:1;justify-content:center;overflow:hidden;min-width:150px;}
.tb-title{font-weight:700;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;font-size:16px;text-align:center;}
.fpd-back{color:#111;text-decoration:none;font-weight:600;margin-right:6px;padding:6px 12px;border:1px solid #111;border-radius:6px;}
.fpd-back:hover{background:#111;color:#fff;}

/* View switches */
.view-switch button{
    background:transparent;
    border:2px solid #111;
    padding:8px 16px;
    margin-left:6px;
    border-radius:6px;
    font-weight:600;
    cursor:pointer;
    transition: all 0.2s;
}
.view-switch button:hover{background:#f5f5f5;}
.view-switch button.active{background:#111;color:#fff;}

/* Price and cart */
.price{font-weight:700;margin-left:8px;font-size:18px;}
.add-cart{
    background:#111;
    color:#fff;
    border:none;
    padding:10px 20px;
    border-radius:6px;
    cursor:pointer;
    font-weight:600;
    font-size:14px;
    transition: all 0.2s;
}
.add-cart:hover{background:#333;}
.add-cart:disabled{background:#ccc;cursor:not-allowed;}

/* Main content area with sidebar */
.fpd-content{
    display:flex;
    flex:1;
    overflow:hidden;
}

/* Left sidebar - ALWAYS VISIBLE on desktop */
.fpd-tools{
    width:320px;
    background:#fff;
    border-right:2px solid #111;
    overflow-y:auto;
    flex-shrink:0;
}

/* Mobile: tools at bottom */
@media(max-width:768px){
    .fpd-content{flex-direction:column-reverse;}
    .fpd-tools{
        width:100%;
        max-height:40vh;
        border-right:none;
        border-top:2px solid #111;
    }
}

.tools-inner{padding:20px;}

.tool-section{
    margin-bottom:25px;
    padding-bottom:20px;
    border-bottom:1px solid #eee;
}
.tool-section:last-child{border-bottom:none;}

.tool-section h4{
    margin:0 0 12px 0;
    font-size:15px;
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:0.5px;
}

/* Buttons */
.fpd-btn{
    display:block;
    width:100%;
    padding:12px;
    border:2px solid #111;
    background:transparent;
    color:#111;
    border-radius:6px;
    margin-top:8px;
    cursor:pointer;
    font-weight:600;
    transition: all 0.2s;
    font-size:14px;
}
.fpd-btn:hover{background:#111;color:#fff;}
.fpd-btn:active{transform:scale(0.98);}

/* Inputs */
.fpd-input{
    width:100%;
    padding:10px;
    border:2px solid #ddd;
    border-radius:6px;
    margin-top:8px;
    font-size:14px;
}
.fpd-input:focus{
    outline:none;
    border-color:#111;
}

/* Text settings panel */
#text-settings{
    margin-top:15px;
    padding:15px;
    background:#f8f8f8;
    border-radius:6px;
}
#text-settings label{
    display:block;
    margin-bottom:10px;
    font-size:13px;
    font-weight:600;
}

/* Upload area */
.upload-area{
    display:block;
    border:2px dashed #111;
    padding:30px 20px;
    text-align:center;
    border-radius:8px;
    cursor:pointer;
    color:#333;
    position:relative;
    overflow:hidden;
    transition: all 0.2s;
    background:#f8f8f8;
    font-weight:600;
}
.upload-area:hover{
    background:#eee;
    border-color:#000;
}
.upload-area input[type=file]{
    position:absolute;
    left:0;
    top:0;
    right:0;
    bottom:0;
    opacity:0;
    cursor:pointer;
}

/* Addon list */
.addon-item{
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:10px;
    border:1px solid #eee;
    border-radius:6px;
    margin-bottom:8px;
    background:#f8f8f8;
}
.addon-item input[type=checkbox]{
    margin-right:10px;
    width:18px;
    height:18px;
    cursor:pointer;
}
.addon-price{
    font-weight:700;
    color:#111;
}

/* Canvas area */
.fpd-canvas-wrap{
    flex:1;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
    background:#f7f7f7;
    overflow:auto;
    position: relative;
    z-index: 1;
}

.canvas-holder{
    width:100%;
    max-width:900px;
    display:flex;
    align-items:center;
    justify-content:center;
    position: relative;
    z-index: 1;
}

canvas{
    display:block !important;
    border-radius:8px;
    background:#fff;
    box-shadow:0 4px 20px rgba(0,0,0,0.1);
    max-width:100%;
    height:auto;
    position: relative !important;
    z-index: 10 !important;
    pointer-events: auto !important;
}

/* Fabric.js canvas wrapper */
.canvas-container {
    position: relative !important;
    display: block !important;
    z-index: 10 !important;
    pointer-events: auto !important;
}

/* Lower canvas (background) */
.lower-canvas {
    position: absolute !important;
    display: block !important;
    pointer-events: none !important;
}

/* Upper canvas (interactive layer) - THIS IS KEY */
.upper-canvas {
    position: absolute !important;
    display: block !important;
    z-index: 2 !important;
    pointer-events: auto !important;
    cursor: move !important;
    touch-action: pan-x pan-y pinch-zoom !important;
}

/* Desktop adjustments */
@media(min-width:900px){
    .fpd-tools{
        width:340px;
    }
    .fpd-topbar{
        padding:12px 20px;
    }
}

/* Loading and error screens - HIDDEN BY DEFAULT */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: none; /* Changed to none by default */
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 20px;
}

#loading-screen .spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #111;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

.error-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    z-index: 10000;
}

.error-screen.show { display: flex; }
.error-screen h2 { color: #d00; margin-bottom: 10px; }
.error-screen pre {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
    max-width: 600px;
    overflow: auto;
    text-align: left;
    margin: 20px 0;
}

/* Remove old slide-in styles */
.tool-close{display:none;}
.fpd-icons{display:none;}

/* Ensure body scroll is allowed */
body,html{overflow:auto !important;}

/* Print styles */
@media print {
    .fpd-topbar,
    .fpd-tools {
        display: none !important;
    }
    .fpd-canvas-wrap {
        padding: 0;
        background: white;
    }
}

/* --- MOBILE OPTIMIZATIONS (App-Like Top Nav) --- */
@media (max-width: 900px) {
    /* Compact Top Bar */
    .fpd-topbar { padding: 0 10px; height: 50px; position: fixed; top: 0; width: 100%; z-index: 1000; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
    
    /* Logo Fix */
    .logo { font-size: 18px; }
    .logo img { height: 24px; width: auto; vertical-align: middle; }
    
    .tb-right { gap: 10px; }
    .price-display { display: none; } 
    .add-cart { padding: 6px 12px; font-size: 12px; white-space: nowrap; }
    .btn-back { display: none; } 
    
    .tb-left::before {
        content: '←';
        font-size: 24px;
        margin-right: 10px;
        cursor: pointer;
        display: block;
        line-height: 1;
    }
    .tb-left { gap: 5px; cursor: pointer; }

    /* Layout reset for mobile - use Flexbox to avoid Overlap */
    .fpd-content { 
        display: flex;
        flex-direction: column;
        flex: 1; 
        height: auto;
        width: 100vw;
        padding-top: 0;
        overflow: hidden;
        position: relative;
    }
    
    /* Tools Area: Sits below Header naturally in Flex flow */
    .fpd-tools { 
        position: relative; 
        top: 50px; /* Offset for fixed header */
        width: 100%;
        height: 55px; /* Height of just the Nav Bar */
        z-index: 300; /* Stacking priority */
        background: #fff;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        display: flex;
        flex-direction: column; /* Nav first */
        border: none;
        border-bottom: 1px solid #eee;
        flex-shrink: 0;
        overflow: visible; /* Allow popup content to overflow */
    }
    
    /* Nav Bar */
    .fpd-sidebar-nav {
        width: 100%;
        height: 55px;
        flex-direction: row; 
        border: none;
        padding: 0;
        justify-content: space-around;
        background: #fff;
        pointer-events: auto;
    }
    
    .nav-item { flex: 1; padding: 8px; }
    .nav-item.active::before { width: 50%; left: 25%; height: 3px; top: auto; bottom: 0; }
    
    .nav-icon { margin-bottom: 2px; font-size: 18px; }
    .nav-label { font-size: 10px; }
    
    /* Content Panels - Overlay Style (Absolute relative to fpd-tools) */
    .fpd-sidebar-content {
        position: absolute;
        top: 55px; /* Sits directly below nav bar */
        left: 0;
        width: 100%;
        background: #fff;
        border-bottom: 1px solid #eee;
        box-shadow: 0 4px 10px rgba(0,0,0,0.1);
        overflow-y: auto;
        display: block;
        max-height: 50vh; 
    }
    
    /* Hide content when collapsed */
    .fpd-tools.collapsed .fpd-sidebar-content {
        display: none;
    }

    /* Canvas Area: Fills remaining space */
    .fpd-canvas-wrap { 
        position: absolute;
        top: 105px; /* 50px Header + 55px Nav */
        left: 0;
        width: 100%;
        height: calc(100% - 105px);
        padding: 10px;
        padding-top: 20px;
        justify-content: flex-start;
        background-size: 15px 15px;
        z-index: 200; /* Below Tools */
        overflow: auto;
    }
    
    /* Toolbar Scroll - MOVED TO RIGHT SIDE */
    .canvas-toolbar {
        position: absolute;
        width: auto;
        right: 10px;
        left: auto;
        top: 20px; /* Inside canvas wrap padding */
        transform: none;
        padding: 4px;
        justify-content: flex-start;
        flex-direction: column; /* Stack vertically */
        align-items: flex-end;
        background: transparent;
        box-shadow: none;
        z-index: 250;
    }
    
    /* Mobile Toolbar Buttons: Round Icons */
    .toolbar-btn { 
        background: white; 
        box-shadow: 0 2px 5px rgba(0,0,0,0.2); 
        margin-bottom: 8px; 
        border-radius: 50%; 
        width: 40px; 
        height: 40px; 
        justify-content: center;
        padding: 0;
    }
    /* Replace text with Icons via CSS for mobile */
    #view-front { font-size: 0; }
    #view-front::after { content: 'Front'; font-size: 10px; display: none; } /* Or use an icon font */
    #view-front::before { content: 'F'; font-size: 14px; font-weight: bold; }
    
    #view-back { font-size: 0; }
    #view-back::before { content: 'B'; font-size: 14px; font-weight: bold; }

    .fpd-panel { padding: 15px; }
    .upload-area { padding: 24px 16px; }
    .shape-grid { grid-template-columns: repeat(4, 1fr); }

    /* Compact Inputs */
    .fpd-input { padding: 6px 10px; margin-top: 4px; font-size: 13px; height: 36px; }
    .fpd-btn { padding: 8px; font-size: 13px; margin-bottom: 6px; }
    .input-group { margin-bottom: 8px; }
    .input-group label { font-size: 11px; margin-bottom: 2px; }
    .fpd-color-input { height: 32px; padding: 1px; }
    
    /* --- COMPACT ACTIVE SETTINGS (Two Rows) --- */
    .active-settings {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        position: fixed;
        top: 105px; /* Below Header (50) + Nav (55) */
        left: 0;
        width: 100%;
        background: #fff;
        padding: 10px 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        z-index: 1000;
        border-bottom: 1px solid #eee;
        align-items: center;
    }

    /* ROW 1: Text Input (Left) + Font Select (Right) */
    .active-settings .input-group:nth-child(1) { 
        width: 58%; 
        order: 1; 
        margin-bottom: 5px; 
    }
    .active-settings .input-group:nth-child(2) { 
        width: 40%; 
        order: 2; 
        margin-bottom: 5px; 
    }

    /* ROW 2: Colors (Left) + Slider (Right) */
    /* Text Color */
    .active-settings .input-group:nth-child(3) {
        width: 40px;
        order: 3;
        margin-bottom: 0;
    }
    /* Outline Color */
    .active-settings .input-group:nth-child(4) {
        width: 40px;
        order: 4;
        margin-bottom: 0;
        margin-left: 5px;
    }
    /* Outline Width Slider */
    .active-settings .input-group:nth-child(5) {
        flex: 1; /* Take remaining space */
        order: 5;
        margin-bottom: 0;
        margin-left: 10px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    /* Labels styling for compact view */
    .active-settings label { 
        font-size: 10px; 
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Round Color Inputs */
    .active-settings input[type="color"] {
        width: 35px;
        height: 35px;
        border-radius: 50%;
        padding: 0;
        border: 2px solid #ddd;
        overflow: hidden;
        -webkit-appearance: none;
        background: transparent;
    }
    .active-settings input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
    .active-settings input[type="color"]::-webkit-color-swatch { border: none; border-radius: 50%; }

    /* Slider styling */
    .active-settings input[type="range"] {
        width: 100%;
        margin-top: 5px;
    }
    
    /* Ensure inputs fit */
    .active-settings .fpd-input {
        height: 36px;
        font-size: 13px;
        padding: 4px 8px;
    }
}
/* ============================= */
/* LEFT SIDEBAR UI IMPROVEMENTS */
/* ============================= */

/* Sidebar container */
.fpd-tools {
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
}

/* Nav strip */
.fpd-sidebar-nav {
    background: #ffffff;
    border-right: 1px solid #e5e7eb;
    padding-top: 8px;
}

/* Nav item */
.nav-item {
    padding: 14px 6px;
    gap: 6px;
    color: #6b7280;
}

/* Icon */
.nav-icon {
    font-size: 18px;
    line-height: 1;
}

/* Label */
.nav-label {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* Hover state */
.nav-item:hover {
    background: #f9fafb;
    color: #111827;
}

/* Active state */
.nav-item.active {
    background: #f3f4f6;
    color: #111827;
    font-weight: 600;
}

.nav-item.active::before {
    background: #111827;
}

/* Content panel */
.fpd-sidebar-content {
    background: #ffffff;
}

/* Panel padding refinement */
.fpd-panel {
    padding: 20px;
}

/* Section headers */
.section-header h4 {
    font-size: 15px;
    font-weight: 600;
}

/* Product card */
.product-info {
    background: #fafafa;
    border: 1px solid #e5e7eb;
}

/* Upload box */
.upload-area {
    border-color: #d1d5db;
    background: #fafafa;
}

.upload-area:hover {
    background: #ffffff;
    border-color: #111827;
}

/* Shape buttons */
.shape-btn {
    font-size: 20px;
    border-radius: 10px;
}
/* ============================= */
/* BEBAS NEUE – LEFT SIDEBAR UI */
/* ============================= */

/* Sidebar navigation labels */
.fpd-sidebar-nav,
.fpd-sidebar-nav .nav-label {
    letter-spacing: 0.8px;
}

/* Section titles */
.fpd-panel .section-header h4 {
    letter-spacing: 0.6px;
}

/* Buttons inside sidebar */
.fpd-panel .fpd-btn {
    letter-spacing: 0.8px;
    font-size: 15px;
}

/* Product title */
.product-details h4 {
    letter-spacing: 0.7px;
}

/* Price badge */
.product-price-badge {
    letter-spacing: 0.6px;
}
.nav-icon.dashicons {
    font-size: 20px;
    width: auto;
    height: auto;
}
/* Toolbar base */
.canvas-toolbar {
    display: flex;
    gap: 6px;
    background: #fff;
    padding: 6px;
    border-radius: 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

/* Buttons */
.toolbar-btn {
    border: none;
    background: transparent;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #374151;
    transition: all 0.2s ease;
}

.toolbar-btn:hover {
    background: #f3f4f6;
}

/* Active view */
.toolbar-btn.active {
    background: #111827;
    color: #fff;
}

/* Front / Back buttons */
.view-btn {
    letter-spacing: 1px;
}

.view-icon {
    display: none;
}

/* Delete button */
.toolbar-btn.danger:hover {
    background: #fee2e2;
    color: #b91c1c;
}

/*  MOBILE OPTIMIZATION */
@media (max-width: 900px) {
    .toolbar-btn {
        padding: 8px;
        width: 42px;
        height: 42px;
        justify-content: center;
    }

    .view-text {
        display: none;
    }

    .view-icon {
        display: inline-block;
        font-size: 16px;
        font-weight: 700;
    }
}
/* DESKTOP: toolbar sits above canvas, not over it */
@media (min-width: 901px) {
    .canvas-toolbar {
        position: relative;
        top: 0;
        left: 0;
        transform: none;
        margin-bottom: 12px;
        background: #ffffff;
        padding: 8px;
        border-radius: 12px;
        box-shadow: 0 4px 14px rgba(0,0,0,0.08);
    }

    .fpd-canvas-wrap {
        padding-top: 0 !important;
    }
}
