/* ==========================================
   LUMUS ADMIN - CSS VARIABLES & RESET
   ========================================== */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-dark: #02000a;
    --neon-cyan: #00f0ff;
    --neon-purple: #a855f7;
    --neon-pink: #ff0055;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Base Styles */
.text-gradient {
    background: linear-gradient(135deg, var(--neon-cyan), var(--neon-purple));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.glass-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
}

.glass-panel.padded {
    padding: 2rem;
}

.divider {
    border: 0;
    height: 1px;
    background: var(--glass-border);
    margin: 2rem 0;
}

/* ==========================================
   FORM COMPONENTS
   ========================================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-family: 'Space Grotesk', sans-serif;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.visual-editor-block input,
.visual-editor-block textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.visual-editor-block input:focus,
.visual-editor-block textarea:focus {
    outline: none;
    border-color: var(--neon-cyan);
    background: rgba(0, 240, 255, 0.05);
}

.neon-btn {
    position: relative;
    padding: 1rem 2rem;
    background: transparent;
    color: white;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border: 1px solid var(--neon-cyan);
    border-radius: 50px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.neon-btn.small {
    padding: 0.6rem 1.5rem;
    width: auto;
    font-size: 0.8rem;
}

.neon-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(0, 240, 255, 0.4), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
    z-index: 1;
}

.neon-btn:hover::before {
    transform: translateX(100%);
}

.neon-btn:hover {
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
    background: rgba(0, 240, 255, 0.1);
}

.neon-btn span {
    position: relative;
    z-index: 2;
}

/* ==========================================
   VIEWS MANAGEMENT
   ========================================== */
.admin-view {
    display: none;
    min-height: 100vh;
}

.admin-view.active {
    display: flex;
}

/* ==========================================
   LOGIN SCREEN
   ========================================== */
#login-screen {
    justify-content: center;
    align-items: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 3rem 2rem;
    text-align: center;
}

.login-header {
    margin-bottom: 2rem;
}

.login-header h2 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.error-msg {
    color: var(--neon-pink);
    margin-top: 1rem;
    font-size: 0.85rem;
    min-height: 20px;
}

/* ==========================================
   DASHBOARD LAYOUT
   ========================================== */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    border-radius: 0;
    border-left: none;
    border-top: none;
    border-bottom: none;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    width: 0;
    min-width: 0;
    padding: 0;
    margin: 0;
    border: none;
    overflow: hidden;
}

.sidebar-brand {
    padding: 2rem;
    border-bottom: 1px solid var(--glass-border);
}

.sidebar-nav {
    flex: 1;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    background: transparent;
    border: none;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    text-align: left;
    width: 100%;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--neon-cyan);
    background: rgba(0, 240, 255, 0.08);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--glass-border);
}

.text-danger {
    color: var(--neon-pink);
}

.text-danger:hover {
    background: rgba(255, 0, 85, 0.1);
    color: var(--neon-pink);
}

/* MAIN CONTENT AREA */
.main-content {
    flex: 1;
    padding: 3rem;
    overflow-y: auto;
}

.content-view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.content-view.active {
    display: block;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

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

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

/* ==========================================
   VISUAL EDITOR STYLES (MATCHES LIVE SITE)
   ========================================== */
.visual-editor-block {
    border-left: 4px solid var(--neon-purple);
    padding: 2rem 1.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(90deg, rgba(168, 85, 247, 0.05) 0%, transparent 100%);
    border-radius: 0 8px 8px 0;
}

.visual-editor-block h3 {
    color: var(--neon-purple);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 1.5rem;
    font-family: 'Space Grotesk', sans-serif;
}

.editor-preview-hero {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.editor-preview-hero input#hero-slogan {
    text-align: center;
    border-radius: 50px;
    width: 60%;
    color: var(--neon-cyan);
    border-color: var(--neon-cyan);
    font-size: 0.8rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: rgba(0, 240, 255, 0.1);
}

.editor-preview-hero input#hero-title-1,
.editor-preview-hero input#hero-title-2 {
    font-size: 2.2rem;
    text-align: center;
    background: transparent;
    border: 1px dashed var(--glass-border);
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    padding: 1.5rem;
}

.editor-preview-hero textarea#hero-sub {
    text-align: center;
    font-size: 1rem;
    color: var(--text-secondary);
    width: 80%;
}

.editor-preview-about {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.editor-preview-about input#about-title {
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    border: 1px dashed var(--glass-border);
    background: transparent;
    color: var(--neon-cyan);
}

.editor-preview-about textarea#about-text {
    font-size: 1rem;
    line-height: 1.6;
    height: 200px;
    color: var(--text-secondary);
}

/* =========================================
   GERADOR DE ORÇAMENTOS (QUOTE GENERATOR) 
   ========================================= */

#quote-editor:focus {
    outline: none;
    box-shadow: inset 0 0 15px rgba(0, 240, 255, 0.05);
}

#quote-editor {
    transition: all 0.3s ease;
}

#quote-editor::-webkit-scrollbar {
    width: 6px;
}

#quote-editor::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

#quote-editor::-webkit-scrollbar-thumb {
    background: var(--neon-cyan);
    border-radius: 4px;
}

/* Base resets to avoid breaking the complex Canva-like HTML injected */
#quote-editor * {
    max-width: 100%;
}

#quote-editor li {
    margin-bottom: 0.5rem;
}

/* Scaling container for the A4 live preview */
#pdf-preview-scale-wrapper {
    /* 
      A4 Portrait at 96 DPI = 794 x 1123 
      We scale it down via JS/Inline to fit typical screens 
    */
    background-color: #09090b;
    transition: background 0.5s ease;
}

#pdf-preview-scale-wrapper.clean-mesh-bg {
    background-color: #f8fafc !important;
    background-image:
        radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(147, 51, 234, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.15) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(14, 165, 233, 0.15) 0px, transparent 50%) !important;
}

/* =========================================
   PRO TEMPLATE BUTTONS (Tailwind/Glass)
   ========================================= */
.pro-template-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    padding: 0.7rem 0.8rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.pro-template-btn i {
    font-size: 1.1rem;
    color: #818cf8;
    transition: all 0.3s;
}

.pro-template-btn:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.2), 0 4px 6px -2px rgba(79, 70, 229, 0.1);
    color: #fff;
}

.pro-template-btn:hover i {
    color: #c084fc;
}

#pdf-capture-area {
    /* Absolute metric sizing to guarantee exact aspect ratio for html2pdf rendering */
    width: 794px !important;
    min-height: 1123px;
    /* Allow dynamic growth beyond A4 */
    padding-bottom: 120px !important;
    /* Ensure space for absolute footer at the bottom */
    position: relative;
    background: #0a0a0f;
    transition: background 0.4s ease, color 0.4s ease;
}

#pdf-capture-area.theme-dark {
    --bg-color: #0a0a0f;
    --text-base: #cbd5e1;
    --heading-color: #ffffff;
    --card-bg: rgba(20, 20, 25, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.4);
    --secondary-bg: rgba(20, 20, 25, 0.8);
    --secondary-border: rgba(255, 255, 255, 0.1);
    --sec-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.3);
    --muted-bg: rgba(0, 0, 0, 0.3);
    --muted-text: #94a3b8;
    --highlight-text: #e2e8f0;
    --icon-bg: rgba(255, 255, 255, 0.05);
    --icon-border: rgba(255, 255, 255, 0.1);
    --icon-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
    --white-always: #ffffff;
    --dark-grad-1: #0F172A;
    --dark-grad-2: #1e1b4b;
    --divider-color: rgba(255, 255, 255, 0.1);
    --mesh-blob-1: rgba(168, 85, 247, 0.15);
    --mesh-blob-2: rgba(0, 240, 255, 0.1);
    --frame-border: rgba(255, 255, 255, 0.05);

    background: var(--bg-color);
    color: var(--text-base);
}

#pdf-capture-area.theme-light {
    --bg-color: #f8fafc;
    --text-base: #475569;
    --heading-color: #0F172A;
    --card-bg: rgba(255, 255, 255, 0.5);
    --card-border: rgba(255, 255, 255, 0.6);
    --card-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.05);
    --secondary-bg: rgba(255, 255, 255, 0.7);
    --secondary-border: rgba(255, 255, 255, 0.8);
    --sec-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.05);
    --muted-bg: rgba(255, 255, 255, 0.5);
    --muted-text: #64748b;
    --highlight-text: #1e293b;
    --icon-bg: #ffffff;
    --icon-border: #f1f5f9;
    --icon-shadow: 0 2px 10px -2px rgba(0, 0, 0, 0.05);
    --white-always: #ffffff;
    --dark-grad-1: #0F172A;
    --dark-grad-2: #1e1b4b;
    --divider-color: rgba(226, 232, 240, 0.6);
    --mesh-blob-1: rgba(79, 70, 229, 0.08);
    /* Indigo */
    --mesh-blob-2: rgba(236, 72, 153, 0.08);
    /* Pink */
    --frame-border: rgba(15, 23, 42, 0.05);

    background: var(--bg-color);
    color: var(--text-base);
}

/* =========================================
   TOOL-BTN (Canva-like Toolbar UI)
   ========================================= */
.tool-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #e2e8f0;
    padding: 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.tool-btn:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.95);
}

.color-picker-wrapper:hover {
    background: rgba(255, 255, 255, 0.1) !important;
}

/* =========================================
   HISTÓRICO DE ORÇAMENTOS
   ========================================= */
.historico-card {
    background: rgba(20, 20, 25, 0.95);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: all 0.3s ease;
}

.historico-card:hover {
    border-color: var(--neon-cyan);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 240, 255, 0.1);
}

.historico-date {
    font-size: 0.8rem;
    color: #888;
    font-family: monospace;
}

.historico-client {
    font-size: 1.2rem;
    color: #fff;
    font-weight: 600;
}

.historico-project {
    color: var(--neon-cyan);
    font-size: 0.9rem;
}

.historico-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

/* =========================================
   RETRACTABLE SIDEBAR LAYOUT
   ========================================= */
#left-control-panel {
    opacity: 1;
    transform: translateX(0);
    transform-origin: left top;
}

#left-control-panel.collapsed {
    flex: 0 0 0% !important;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50px);
    margin-right: -2rem;
    /* Negate the gap */
    overflow: hidden;
    padding: 0;
    height: 0;
}

#right-preview-panel.expanded {
    flex: 1 1 100% !important;
}

#right-preview-panel.expanded #preview-scroll-container {
    max-width: 100% !important;
    height: 85vh;
}

#right-preview-panel.expanded #pdf-preview-scale-wrapper {
    /* When expanded, we scale it up nicely to fill the newly available space */
    transform: scale(0.9) !important;
}

/* =========================================
   CANVA BLOCK EDITOR STYLES
   ========================================= */
.block-editor-container {
    padding-bottom: 50px !important;
}

.editor-block {
    position: relative;
    border: 2px dashed transparent;
    transition: all 0.2s;
    cursor: default;
}

/* Hover state to indicate it's a structural block */
.block-editor-container:focus-within .editor-block:hover {
    border-color: rgba(99, 102, 241, 0.3);
    border-radius: 8px;
}

/* Selected/Active Block State */
.editor-block.is-active {
    border: 2px solid #6366f1 !important;
    border-radius: 8px;
    background-color: rgba(99, 102, 241, 0.05);
}

/* The actual text regions inside a block are editable, not the whole block wrapper */
.editor-block [contenteditable="true"] {
    outline: none !important;
    cursor: text;
}

.editor-block [contenteditable="true"]:focus {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

/* Floating Context Menu Buttons */
.context-btn {
    background: transparent;
    border: none;
    color: #e2e8f0;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.context-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.add-block-btn {
    color: #a5b4fc;
    border-color: rgba(165, 180, 252, 0.2);
    font-size: 13px;
    padding: 6px 12px;
}

.add-block-btn:hover {
    background: rgba(165, 180, 252, 0.1);
    color: #c7d2fe;
}

/* =========================================
   FREE-TRANSFORM HANDLES (Phase 2)
   ========================================= */
/* Bounding block removed */

.transform-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid #6366f1;
    border-radius: 50%;
    z-index: 50;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    /* Initially hidden unless active */
    display: none;
}

.editor-block.is-active .transform-handle {
    display: block;
}

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

.rotate-t {
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    cursor: grab;
    width: 14px;
    height: 14px;
    background: #6366f1;
    border: 2px solid #fff;
}

.rotate-t:active {
    cursor: grabbing;
}

/* A little line connecting the rotation handle to the block */
.rotate-t::after {
    content: '';
    position: absolute;
    width: 2px;
    height: 12px;
    background: #6366f1;
    top: 10px;
    left: 4px;
    z-index: -1;
}

/* Fix visibility issues */
.context-btn i,
.tool-btn i,
.add-block-btn i {
    color: #fff !important;
}

.context-btn {
    color: #fff !important;
}

/* Ensure sidebar toggle buttons are highly visible */
#global-sidebar-toggle,
#floating-sidebar-toggle {
    color: #fff !important;
    background: rgba(0, 0, 0, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
}

#global-sidebar-toggle svg,
#floating-sidebar-toggle svg {
    stroke: #fff !important;
}