/* =========================================
RESET
========================================= */

*{
    margin:0;
    padding:0;
    box-sizing:border-box;
}

html,
body{
    width:100%;
    height:100%;
    overflow:hidden;
}

body{
    font-family:'Inter',sans-serif;
    background:#eef2f7;
    color:#111827;
}

/* =========================================
LAYOUT
========================================= */

.editor-layout{
    width:100vw;
    height:100vh;

    display:flex;
    align-items:stretch;

    gap:16px;
    padding:16px;

    overflow:hidden;
}

/* =========================================
LEFT SIDEBAR
========================================= */

.left-sidebar{
    width:82px;
    min-width:82px;
    height:calc(100vh - 32px);

    background:#f8fafc;

    border-radius:28px;

    border:1px solid #e5e7eb;

    display:flex;
    flex-direction:column;
    align-items:center;

    padding:14px 8px;

    overflow-y:auto;

    flex-shrink:0;

    position:relative;
    z-index:100;
}

/* SCROLLBAR */

.left-sidebar::-webkit-scrollbar{
    width:5px;
}

.left-sidebar::-webkit-scrollbar-thumb{
    background:#6366f1;
    border-radius:20px;
}

/* =========================================
LOGO
========================================= */

.sidebar-logo{
    width:56px;
    height:56px;

    border-radius:18px;

    background:#ffffff;

    display:flex;
    align-items:center;
    justify-content:center;

    margin-bottom:18px;

    font-size:14px;
    font-weight:800;

    color:#ef4444;

    box-shadow:
    0 5px 20px rgba(0,0,0,.05);
}

/* =========================================
SIDEBAR TOOLS
========================================= */

.sidebar-tools{
    width:100%;

    display:flex;
    flex-direction:column;
    align-items:center;

    gap:10px;
}

/* =========================================
TOOL BUTTON
========================================= */

.tool-btn{
    width:56px;
    min-height:56px;

    border:none;

    border-radius:18px;

    background:transparent;

    display:flex;
    flex-direction:column;
    align-items:center;
    justify-content:center;

    gap:4px;

    cursor:pointer;

    transition:.25s ease;

    position:relative;
}

.tool-btn i{
    font-size:18px;
    color:#64748b;
}

.tool-btn span{
    font-size:11px;
    font-weight:600;
    color:#64748b;
}

/* ACTIVE */

.tool-btn.active{
    background:linear-gradient(
        135deg,
        #5b3df5,
        #7c3aed
    );

    box-shadow:
    0 12px 25px rgba(91,61,245,.25);
}

.tool-btn.active i,
.tool-btn.active span{
    color:#ffffff;
}

/* HOVER */

.tool-btn:hover{
    background:#ede9fe;
}

.tool-btn:hover i,
.tool-btn:hover span{
    color:#4f46e5;
}

/* TEMPLATE BTN FIX */

#templatesBtn{
    position:relative;
    z-index:99999;
    cursor:pointer;
}

#templatesBtn i,
#templatesBtn span{
    pointer-events:none;
}

/* =========================================
TEMPLATE OVERLAY
========================================= */

.templates-overlay{
    position:fixed;
    inset:0;

    background:rgba(15,23,42,.45);

    backdrop-filter:blur(6px);

    z-index:9998;

    opacity:0;
    visibility:hidden;

    transition:.3s ease;
}

.templates-overlay.active{
    opacity:1;
    visibility:visible;
}

/* =========================================
TEMPLATE POPUP PANEL
========================================= */

.templates-panel{
    position:fixed;

    top:50%;
    left:50%;

    transform:
    translate(-50%, -50%)
    scale(.92);

    width:430px;
    max-width:92vw;

    height:86vh;

    background:#ffffff;

    border-radius:32px;

    z-index:99999;

    overflow:hidden;

    opacity:0;
    visibility:hidden;

    transition:.3s ease;

    box-shadow:
    0 30px 90px rgba(0,0,0,.18);

    display:flex;
    flex-direction:column;
}

/* SHOW */

.templates-panel.active{
    opacity:1;
    visibility:visible;

    transform:
    translate(-50%, -50%)
    scale(1);
}

/* =========================================
PANEL HEADER
========================================= */

.panel-header{
    display:flex;
    align-items:center;
    justify-content:space-between;

    padding:24px;

    border-bottom:1px solid #e5e7eb;
}

.panel-header h2{
    font-size:28px;
    font-weight:800;
}

/* CLOSE BUTTON */

.close-panel{
    width:42px;
    height:42px;

    border:none;

    border-radius:14px;

    background:#f3f4f6;

    cursor:pointer;

    font-size:18px;

    transition:.2s;
}

.close-panel:hover{
    background:#e5e7eb;
}

/* =========================================
SEARCH
========================================= */

.search-wrap{
    position:relative;
    padding:20px;
}

.search-wrap i{
    position:absolute;

    left:38px;
    top:38px;

    color:#94a3b8;
}

.template-search{
    width:100%;
    height:56px;

    border:none;

    border-radius:18px;

    background:#f8fafc;

    padding:0 18px 0 48px;

    font-size:15px;

    outline:none;
}

/* =========================================
UPLOAD
========================================= */

.template-upload-box{
    padding:0 20px 20px;
}

.upload-template-btn{
    width:100%;
    height:56px;

    border:none;

    border-radius:18px;

    background:linear-gradient(
        135deg,
        #4f46e5,
        #2563eb
    );

    color:#ffffff;

    font-size:15px;
    font-weight:700;

    cursor:pointer;

    transition:.25s ease;
}

.upload-template-btn:hover{
    transform:translateY(-2px);

    box-shadow:
    0 12px 25px rgba(79,70,229,.25);
}

/* =========================================
TEMPLATE GRID
========================================= */

.template-grid{
    flex:1;

    overflow-y:auto;

    padding:0 20px 20px;

    display:flex;
    flex-direction:column;

    gap:18px;
}

/* SCROLLBAR */

.template-grid::-webkit-scrollbar{
    width:6px;
}

.template-grid::-webkit-scrollbar-thumb{
    background:#6366f1;
    border-radius:20px;
}

/* =========================================
TEMPLATE ITEM
========================================= */

.template-item{
    background:#ffffff;

    border:1px solid #e5e7eb;

    border-radius:24px;

    overflow:hidden;

    cursor:pointer;

    transition:.25s ease;
}

.template-item:hover{
    transform:translateY(-4px);

    border-color:#4f46e5;

    box-shadow:
    0 15px 40px rgba(79,70,229,.12);
}

.template-item img{
    width:100%;
    height:220px;

    object-fit:cover;

    display:block;
}

.template-info{
    padding:18px;
}

.template-info h4{
    font-size:20px;
    font-weight:700;

    margin-bottom:6px;
}

.template-info p{
    color:#64748b;
    font-size:14px;
}

/* =========================================
MAIN EDITOR
========================================= */

.main-editor{
    flex:1;

    min-width:0;

    height:calc(100vh - 32px);

    background:#ffffff;

    border-radius:32px;

    overflow:hidden;

    display:flex;
    flex-direction:column;

    border:1px solid #e5e7eb;
}

/* =========================================
TOPBAR
========================================= */

.topbar{
    min-height:86px;

    background:#ffffff;

    border-bottom:1px solid #e5e7eb;

    display:flex;
    align-items:center;
    justify-content:space-between;

    padding:0 28px;

    flex-shrink:0;
}

.topbar-left,
.topbar-center,
.topbar-right{
    display:flex;
    align-items:center;
}

.topbar-center{
    gap:12px;
}

.topbar-right{
    gap:14px;
}

/* DOCUMENT NAME */

.document-name{
    display:flex;
    align-items:center;
    gap:10px;

    font-size:18px;
    font-weight:700;
}

/* TOP BUTTON */

.top-btn{
    width:44px;
    height:44px;

    border:none;

    border-radius:14px;

    background:#f3f4f6;

    cursor:pointer;

    font-size:16px;

    transition:.2s;
}

.top-btn:hover{
    background:#e5e7eb;
}

/* ZOOM */

.zoom-level{
    font-size:16px;
    font-weight:600;
}

/* SAVE */

.save-btn{
    height:52px;

    padding:0 24px;

    border:none;

    border-radius:16px;

    background:#eef2ff;

    color:#4f46e5;

    font-weight:700;

    cursor:pointer;
}

/* DOWNLOAD */

.download-btn{
    height:54px;

    padding:0 28px;

    border:none;

    border-radius:18px;

    background:linear-gradient(
        135deg,
        #10b981,
        #059669
    );

    color:#ffffff;

    font-size:15px;
    font-weight:700;

    cursor:pointer;

    transition:.25s;
}

.download-btn:hover{
    transform:translateY(-2px);

    box-shadow:
    0 12px 25px rgba(16,185,129,.25);
}

/* =========================================
TOOLBAR
========================================= */

.toolbar{
    min-height:78px;

    background:#ffffff;

    border-bottom:1px solid #e5e7eb;

    display:flex;
    align-items:center;

    gap:12px;

    padding:0 24px;

    overflow-x:auto;

    flex-shrink:0;
}

/* SCROLLBAR */

.toolbar::-webkit-scrollbar{
    height:4px;
}

.toolbar::-webkit-scrollbar-thumb{
    background:#6366f1;
    border-radius:20px;
}

/* INPUTS */

.toolbar select,
.toolbar input{
    height:48px;

    border:1px solid #d1d5db;

    border-radius:14px;

    background:#ffffff;

    padding:0 14px;

    font-size:15px;

    outline:none;
}

/* FONT SIZE WRAP */

.font-size-wrap{
    display:flex;
    align-items:center;
    gap:8px;
}

#fontSizeSelect{
    width:90px;
}

#fontSizeInput{
    width:80px;
}

/* TOOLBAR BTN */

.toolbar-btn{
    width:46px;
    height:46px;

    border:none;

    border-radius:14px;

    background:#f3f4f6;

    cursor:pointer;

    transition:.2s;
}

.toolbar-btn:hover{
    background:#e5e7eb;
}

/* =========================================
CANVAS AREA
========================================= */

.canvas-area{
    flex:1;

    overflow:auto;

    padding:28px;

    display:flex;
    justify-content:center;
    align-items:flex-start;

    background:#eef2f7;
}

/* SCROLLBAR */

.canvas-area::-webkit-scrollbar{
    width:8px;
    height:8px;
}

.canvas-area::-webkit-scrollbar-thumb{
    background:#6366f1;
    border-radius:20px;
}

/* =========================================
CANVAS CONTAINER
========================================= */

.canvas-container{
    background:#ffffff;

    padding:30px;

    border-radius:30px;

    box-shadow:
    0 20px 60px rgba(0,0,0,.10);

    min-width:900px;
    min-height:1200px;
}

/* CANVAS */

#pdfCanvas{
    border:1px solid #e5e7eb;

    max-width:100%;
}

/* =========================================
SETTINGS PANEL
========================================= */

.settings-panel{
    width:320px;
    min-width:320px;

    height:calc(100vh - 32px);

    background:#ffffff;

    border-radius:32px;

    border:1px solid #e5e7eb;

    padding:24px;

    overflow-y:auto;

    flex-shrink:0;
}

/* SCROLLBAR */

.settings-panel::-webkit-scrollbar{
    width:6px;
}

.settings-panel::-webkit-scrollbar-thumb{
    background:#6366f1;
    border-radius:20px;
}

/* HEADER */

.settings-header{
    margin-bottom:24px;
}

.settings-header h3{
    font-size:30px;
    font-weight:800;
}

/* PROPERTY SECTION */

.property-section{
    margin-top:20px;
}

/* SETTING GROUP */

.setting-group{
    margin-bottom:24px;
}

.setting-group label{
    display:block;

    margin-bottom:10px;

    font-size:14px;
    font-weight:600;
}

.setting-group input{
    width:100%;
}

/* HIDDEN */

.hidden{
    display:none;
}

/* =========================================
RESPONSIVE
========================================= */

@media(max-width:1400px){

    .settings-panel{
        width:280px;
        min-width:280px;
    }

    .canvas-container{
        min-width:800px;
    }

}

@media(max-width:1100px){

    .settings-panel{
        display:none;
    }

}

@media(max-width:768px){

    .editor-layout{
        padding:8px;
        gap:8px;
    }

    .left-sidebar{
        width:70px;
        min-width:70px;

        border-radius:22px;
    }

    .tool-btn{
        width:50px;
        min-height:50px;
    }

    .tool-btn i{
        font-size:16px;
    }

    .tool-btn span{
        font-size:10px;
    }

    .topbar{
        padding:0 14px;
    }

    .toolbar{
        padding:0 14px;
    }

    .document-name{
        font-size:15px;
    }

    .canvas-area{
        padding:12px;
    }

    .canvas-container{
        min-width:700px;
        padding:20px;
    }

    .templates-panel{
        width:94vw;
        height:88vh;
    }

}

/* =========================================
RIGHT SETTINGS PANEL
========================================= */

.settings-panel{

    width:320px;
    min-width:320px;

    height:calc(100vh - 24px);

    background:#ffffff;

    border-radius:28px;

    padding:26px;

    overflow-y:auto;

    flex-shrink:0;

    box-shadow:
    0 15px 40px rgba(0,0,0,.08);

    border:1px solid #e5e7eb;

    transition:.3s ease;

}

/* SCROLLBAR */

.settings-panel::-webkit-scrollbar{

    width:6px;
}

.settings-panel::-webkit-scrollbar-thumb{

    background:#6366f1;
    border-radius:20px;
}

/* HEADER */

.settings-header{

    margin-bottom:28px;

    padding-bottom:18px;

    border-bottom:1px solid #e5e7eb;
}

.settings-header h3{

    font-size:38px;

    font-weight:800;

    color:#0f172a;

    letter-spacing:-1px;
}

/* EMPTY MESSAGE */

#emptyProperties{

    padding:18px;

    border-radius:18px;

    background:#f8fafc;

    border:1px dashed #cbd5e1;

    color:#64748b;

    font-size:15px;

    line-height:1.6;
}

/* PROPERTY SECTION */

.property-section{

    margin-top:22px;

    animation:fadeIn .25s ease;
}

/* GROUP */

.setting-group{

    margin-bottom:24px;
}

/* LABEL */

.setting-group label{

    display:block;

    margin-bottom:10px;

    font-size:14px;

    font-weight:700;

    color:#111827;
}

/* INPUTS */

.setting-group input[type="number"],
.setting-group input[type="text"],
.setting-group select{

    width:100%;

    height:52px;

    border:1px solid #d1d5db;

    border-radius:16px;

    padding:0 16px;

    font-size:15px;

    background:#ffffff;

    outline:none;

    transition:.25s;
}

/* INPUT FOCUS */

.setting-group input:focus,
.setting-group select:focus{

    border-color:#6366f1;

    box-shadow:
    0 0 0 4px rgba(99,102,241,.12);
}

/* COLOR PICKER */

.setting-group input[type="color"]{

    width:100%;

    height:58px;

    border:none;

    border-radius:18px;

    background:none;

    cursor:pointer;

    padding:0;

    overflow:hidden;
}

.setting-group input[type="color"]::-webkit-color-swatch{

    border:none;

    border-radius:18px;
}

.setting-group input[type="color"]::-webkit-color-swatch-wrapper{

    padding:0;
}

/* RANGE */

.setting-group input[type="range"]{

    width:100%;

    accent-color:#5b3df5;

    cursor:pointer;
}

/* TEXT */

.setting-group p{

    font-size:14px;

    color:#64748b;

    line-height:1.6;
}

/* HIDDEN */

.hidden{

    display:none !important;
}

/* PROPERTY CARD STYLE */

.property-section{

    background:#ffffff;

    border:1px solid #eef2f7;

    border-radius:22px;

    padding:20px;

    box-shadow:
    0 4px 15px rgba(0,0,0,.03);
}

/* ACTIVE GLOW */

.property-section.active{

    border-color:#6366f1;

    box-shadow:
    0 10px 30px rgba(99,102,241,.10);
}

/* DIVIDER */

.property-divider{

    height:1px;

    background:#e5e7eb;

    margin:18px 0;
}

/* BUTTON */

.property-btn{

    width:100%;

    height:52px;

    border:none;

    border-radius:16px;

    background:
    linear-gradient(
        135deg,
        #4f46e5,
        #7c3aed
    );

    color:#ffffff;

    font-size:15px;

    font-weight:700;

    cursor:pointer;

    transition:.25s;
}

.property-btn:hover{

    transform:translateY(-2px);

    box-shadow:
    0 12px 24px rgba(79,70,229,.25);
}

/* ANIMATION */

@keyframes fadeIn{

    from{

        opacity:0;
        transform:translateY(10px);
    }

    to{

        opacity:1;
        transform:translateY(0);
    }

}

/* TABLET */

@media(max-width:1100px){

    .settings-panel{

        width:280px;
        min-width:280px;

        padding:20px;
    }

    .settings-header h3{

        font-size:30px;
    }

}

/* MOBILE */

@media(max-width:768px){

    .settings-panel{

        display:none;
    }

}

/* =========================================
FLOATING AI TOOLS POPUP
========================================= */

.dh-floating-tools{
    position:fixed;
    right:24px;
    bottom:24px;
    z-index:999999;
}

/* TOGGLE BUTTON */

.dh-tools-toggle{
    width:68px;
    height:68px;
    border:none;
    border-radius:22px;
    cursor:pointer;
    position:relative;

    background:
    linear-gradient(
    135deg,
    #6d5dfc,
    #8b5cf6,
    #4f46e5);

    color:#fff;
    font-size:24px;

    box-shadow:
    0 20px 50px rgba(79,70,229,.45);

    transition:.35s;
}

.dh-tools-toggle:hover{
    transform:translateY(-4px) scale(1.04);
}

/* PULSE */

.pulse-ring{
    position:absolute;
    inset:-6px;
    border-radius:26px;
    border:2px solid rgba(255,255,255,.5);
    animation:pulse 2s infinite;
}

@keyframes pulse{

    0%{
        transform:scale(.9);
        opacity:1;
    }

    100%{
        transform:scale(1.4);
        opacity:0;
    }

}

/* POPUP */

.dh-tools-popup{
    position:absolute;
    right:0;
    bottom:90px;

    width:360px;

    background:
    rgba(255,255,255,.95);

    backdrop-filter:blur(18px);

    border:
    1px solid rgba(255,255,255,.45);

    border-radius:28px;

    padding:22px;

    box-shadow:
    0 30px 80px rgba(0,0,0,.18);

    opacity:0;
    visibility:hidden;

    transform:
    translateY(20px)
    scale(.96);

    transition:.35s;
}

/* ACTIVE */

.dh-tools-popup.active{
    opacity:1;
    visibility:visible;

    transform:
    translateY(0)
    scale(1);
}

/* HEADER */

.dh-popup-header{
    display:flex;
    align-items:center;
    justify-content:space-between;

    margin-bottom:18px;
}

.dh-popup-header h3{
    margin:0;
    font-size:22px;
    font-weight:800;
    color:#111827;
}

.dh-popup-header p{
    margin:4px 0 0;
    color:#6b7280;
    font-size:13px;
}

.live-badge{
    background:#10b981;
    color:#fff;

    padding:6px 12px;

    border-radius:999px;

    font-size:11px;
    font-weight:700;

    letter-spacing:.5px;
}

/* ITEMS */

.dh-tool-item{
    display:flex;
    align-items:center;
    gap:14px;

    padding:14px;
    margin-bottom:12px;

    border-radius:18px;

    text-decoration:none;

    background:
    linear-gradient(
    135deg,
    rgba(255,255,255,.9),
    rgba(248,250,252,.95));

    border:
    1px solid rgba(99,102,241,.08);

    transition:.28s;
}

.dh-tool-item:hover{
    transform:translateY(-3px);

    background:#fff;

    box-shadow:
    0 18px 40px rgba(99,102,241,.14);
}

.dh-tool-icon{
    width:58px;
    height:58px;

    border-radius:18px;

    display:flex;
    align-items:center;
    justify-content:center;

    color:#fff;
    font-size:22px;

    flex-shrink:0;
}

.gradient-1{
    background:linear-gradient(135deg,#ff6b6b,#ff8e53);
}

.gradient-2{
    background:linear-gradient(135deg,#ef4444,#dc2626);
}

.gradient-3{
    background:linear-gradient(135deg,#06b6d4,#3b82f6);
}

.gradient-4{
    background:linear-gradient(135deg,#8b5cf6,#6d28d9);
}

.gradient-5{
    background:linear-gradient(135deg,#10b981,#059669);
}

.dh-tool-content{
    flex:1;
}

.dh-tool-content h4{
    margin:0 0 4px;
    color:#111827;
    font-size:15px;
    font-weight:700;
}

.dh-tool-content p{
    margin:0;
    color:#6b7280;
    font-size:12px;
    line-height:1.5;
}

.dh-tool-item .fa-arrow-up-right-from-square{
    color:#9ca3af;
    font-size:13px;
}

/* MOBILE */

@media(max-width:768px){

    .dh-floating-tools{
        right:16px;
        bottom:16px;
    }

    .dh-tools-popup{
        width:320px;
    }

}

/* =====================================
UPLOAD TEMPLATE BOX
===================================== */

.template-upload-box{
    margin:20px 0;
}

.upload-template-btn{
    width:100%;
    border:none;
    padding:16px;
    border-radius:18px;
    background:linear-gradient(135deg,#6d5dfc,#8f44fd);
    color:#fff;
    font-weight:700;
    font-size:15px;
    cursor:pointer;
    transition:0.3s ease;
    display:flex;
    align-items:center;
    justify-content:center;
    gap:10px;
    box-shadow:0 10px 30px rgba(109,93,252,.25);
}

.upload-template-btn:hover{
    transform:translateY(-2px);
    box-shadow:0 15px 35px rgba(109,93,252,.4);
}

/* =====================================
TEMPLATE GRID
===================================== */

.template-grid{
    display:grid;
    grid-template-columns:1fr;
    gap:18px;
    margin-top:20px;
}

.template-item{
    background:#fff;
    border-radius:20px;
    overflow:hidden;
    box-shadow:0 10px 25px rgba(0,0,0,.08);
    transition:0.3s ease;
    cursor:pointer;
}

.template-item:hover{
    transform:translateY(-4px);
}

.template-item img{
    width:100%;
    height:170px;
    object-fit:cover;
}

.template-info{
    padding:14px;
}

.template-info h4{
    margin:0 0 6px;
    font-size:16px;
    font-weight:700;
}

.template-info p{
    margin:0;
    font-size:13px;
    color:#777;
}

/* PDF CARD */

.pdf-preview{
    height:170px;
    display:flex;
    align-items:center;
    justify-content:center;
    background:linear-gradient(135deg,#ff4d4d,#ff1f6b);
    color:#fff;
    font-size:60px;
}

.template-item{

    background:#fff;

    border-radius:22px;

    overflow:hidden;

    box-shadow:
    0 10px 35px rgba(0,0,0,.08);

    transition:.3s;

}

.template-item:hover{

    transform:
    translateY(-6px);

}

.template-item img{

    width:100%;

    height:200px;

    object-fit:cover;

    display:block;

}

.template-info{

    padding:14px;

}

.template-info h4{

    margin:0 0 6px;

    font-size:15px;

    font-weight:700;

}

.template-info p{

    margin:0;

    font-size:13px;

    color:#6b7280;

}

/* PDF / WORD PREVIEW */

.pdf-preview{

    width:100%;

    height:200px;

    display:flex;

    align-items:center;

    justify-content:center;

    background:
    linear-gradient(
    135deg,
    #4f46e5,
    #7c3aed);

    color:#fff;

    font-size:70px;

}