/* 
   Resume Builder Specific Styles 
   Overrides to match Business Card Maker Theme Exactly
*/
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #0f172a;
    --sidebar-bg: #1e293b;
    --card-bg: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --input-bg: #020617;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-color: #f1f5f9;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --input-bg: #f8fafc;
}

/* --- Canvas Area (Matches Card Maker) --- */
.canvas-area {
    flex: 1;
    background: #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 2rem;
    overflow: hidden;
    height: 100%;
    max-height: 100%;
}

[data-theme="dark"] .canvas-area {
    background: #0f172a;
    background-image: radial-gradient(#1e293b 1px, transparent 1px);
    background-size: 20px 20px;
}

.resume-wrapper {
    /* Container for pages */
    transition: transform 0.2s ease-out;
    transform-origin: top center;
    background: transparent;
    box-shadow: none;
    padding-bottom: 2rem;
}

.resume-page {
    background: white;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    margin-bottom: 2rem;
    /* Ensure specific margin if flex gap fails */
}

/* --- Controls Panel (Left) --- */
.controls-panel {
    width: 340px;
    /* Fixed width to match Card Maker */
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    height: 100%;
    flex-shrink: 0;
    /* Prevent shrinking */
}

/* Panel Tabs (Matches Card Maker) */
.panel-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 1rem 0.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    border-radius: 0;
    /* Enforce square tabs */
}

.tab-btn:hover {
    color: var(--text-main);
    background: var(--input-bg);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.panel-content {
    padding: 1.5rem;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- Templates Grid --- */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding-right: 5px;
}

.template-item {
    background: white;
    aspect-ratio: 1/1.4;
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
    border: 2px solid transparent;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    font-size: 0.8rem;
    text-align: center;
}

.template-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* --- Accordion Styles (Matches Card Maker) --- */
.accordion-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    overflow: hidden;
    margin-bottom: 0.8rem;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    cursor: pointer;
    background: var(--sidebar-bg);
    font-weight: 600;
    color: var(--text-main);
    transition: background 0.2s;
}

.accordion-header:hover {
    background: var(--input-bg);
}

.accordion-header i:first-child {
    margin-right: 0.5rem;
    color: var(--primary-color);
}

.accordion-content {
    display: none;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.accordion-item.open .accordion-content {
    display: block;
}

.accordion-item.open .caret-icon {
    transform: rotate(180deg);
}

.caret-icon {
    transition: transform 0.2s;
}

/* Text Presets */
.text-presets {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 5px 0;
}

.text-preset-btn {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-main);
    display: flex;
    align-items: center;
}

.text-preset-btn:hover {
    background: var(--sidebar-bg);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-color: var(--primary-color);
    color: var(--text-main);
}

.text-preset-btn span {
    font-family: inherit;
    line-height: 1.2;
    display: block;
    width: 100%;
}

/* Typography specifics for the buttons */
.text-preset-btn.heading span {
    font-size: 1.6rem;
    /* Slightly reduced to prevent wrap */
    font-weight: 800;
    color: var(--text-main);
    white-space: nowrap;
    /* Force single line */
}

.text-preset-btn.subheading span {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-main);
    /* or slightly muted if desired, but headings usually main */
}

.text-preset-btn.body-text span {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-muted);
}

/* --- Upload Area --- */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.upload-area:hover {
    border-color: var(--accent-color);
    background: var(--input-bg);
    color: var(--accent-color);
}

.upload-area i {
    font-size: 2rem;
    margin-bottom: 4px;
}

.upload-area p {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Shapes Grid (Matches Card Maker) */
.shapes-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.shape-btn {
    aspect-ratio: 1;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-main);
    transition: all 0.2s;
}

.shape-btn:hover {
    background: var(--input-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}


/* --- NEW Floating Toolbar (Premium Style) --- */
:root {
    --toolbar-bg: #ffffff;
    --toolbar-border: #e2e8f0;
    --toolbar-shadow: 0 12px 30px -4px rgba(0, 0, 0, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.05);
    --toolbar-text: #1e293b;
    --toolbar-text-muted: #64748b;
    --toolbar-primary: #6366f1;
    --toolbar-primary-hover: #4f46e5;
    --toolbar-primary-soft: #e0e7ff;
    --toolbar-radius: 12px;
}

.floating-toolbar {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toolbar-bg);
    padding: 6px 8px;
    border-radius: var(--toolbar-radius);
    box-shadow: var(--toolbar-shadow);
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 9999;
    width: max-content;
    border: 1px solid var(--toolbar-border);
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    opacity: 1;
}

.floating-toolbar.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 15px) scale(0.98);
}

/* Sections & Dividers */
.toolbar-section {
    display: flex;
    align-items: center;
    gap: 4px;
}

.toolbar-divider {
    width: 1px;
    height: 20px;
    background: var(--toolbar-border);
    margin: 0 6px;
}

/* Buttons */
.toolbar-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 8px;
    color: var(--toolbar-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.2rem;
}

.toolbar-btn:hover {
    background: #f1f5f9;
    color: var(--toolbar-text);
    transform: translateY(-1px);
}

.toolbar-btn.active {
    background: var(--toolbar-primary-soft);
    color: var(--toolbar-primary);
}

.toolbar-btn.danger:hover {
    background: #fef2f2;
    color: #ef4444;
}

/* Inputs & Selects */
.toolbar-select {
    height: 36px;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--toolbar-text);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    outline: none;
    transition: all 0.2s;
}

.toolbar-select:hover {
    background: #f8fafc;
    border-color: var(--toolbar-border);
}

.toolbar-select:focus {
    border-color: var(--toolbar-primary);
    background: white;
    box-shadow: 0 0 0 2px var(--toolbar-primary-soft);
}

.toolbar-input {
    width: 50px;
    height: 36px;
    border: 1px solid transparent;
    border-radius: 8px;
    text-align: center;
    background: transparent;
    color: var(--toolbar-text);
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s;
}

.toolbar-input:hover {
    background: #f8fafc;
    border-color: var(--toolbar-border);
}

.toolbar-input:focus {
    background: white;
    border-color: var(--toolbar-primary);
    box-shadow: 0 0 0 2px var(--toolbar-primary-soft);
    outline: none;
}

/* Color Picker override specifically for toolbar */
.toolbar-color-wrapper {
    position: relative;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
    border: 2px solid white;
    box-shadow: 0 0 0 1px var(--toolbar-border);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toolbar-color-wrapper:hover {
    transform: scale(1.05);
}

.toolbar-color-wrapper input[type="color"] {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    cursor: pointer;
    padding: 0;
    margin: 0;
    border: none;
}

.ft-btn.danger {
    color: #ef4444;
}

.ft-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* --- Canvas Interactive Items --- */
.draggable-item {
    position: absolute;
    cursor: move;
    border: 1px solid transparent;
}

.draggable-item:hover {
    border: 1px dashed var(--primary-color);
}

.draggable-item.selected {
    border: 1px solid var(--primary-color);
}

/* --- Resize Handles --- */
.resize-handle {
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    position: absolute;
    display: none;
    border-radius: 50%;
    z-index: 101;
    border: 1px solid white;
}

.draggable-item.selected .resize-handle {
    display: block;
}

.rh-nw {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.rh-ne {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.rh-sw {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.rh-se {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

/* --- Control Handles (Move/Rotate) --- */
.control-handle {
    width: 24px;
    height: 24px;
    background: white;
    border: 1px solid var(--primary-color);
    border-radius: 50%;
    position: absolute;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 102;
    color: var(--primary-color);
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.draggable-item.selected .control-handle {
    display: flex;
}

.handle-move {
    bottom: -35px;
    /* Position below */
    left: 40%;
    transform: translateX(-50%);
    cursor: move;
}

.handle-rotate {
    bottom: -35px;
    /* Position below */
    left: 60%;
    transform: translateX(-50%);
    cursor: grab;
}

.handle-rotate:active {
    cursor: grabbing;
}

.text-element {
    outline: none;
}

.hidden {
    display: none !important;
}

/* --- Searchable Font Selector --- */
.custom-font-select {
    position: relative;
    width: 140px;
    height: 36px;
}

.font-select-trigger {
    height: 100%;
    width: 100%;
    padding: 0 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--toolbar-text);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    white-space: nowrap;
    transition: all 0.2s;
}

.font-select-trigger:hover {
    background: #f8fafc;
    border-color: var(--toolbar-border);
}

.font-select-trigger span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 90px;
    display: inline-block;
}

/* Dropdown Container */
.font-dropdown {
    position: absolute;
    /* Stick to parent */
    top: calc(100% + 8px);
    /* Below the button + gap */
    left: 0;
    background: #ffffff;
    /* Force white background */
    border: 1px solid var(--toolbar-border);
    border-radius: 12px;
    box-shadow: 0 16px 40px -5px rgba(0, 0, 0, 0.15);
    width: 250px;
    max-height: 350px;
    display: flex;
    flex-direction: column;
    z-index: 20000;
    /* Extremely high z-index */
    overflow: hidden;
    color: #1e293b;
    /* Force dark text color */
}

/* Ensure hidden state works */
.font-dropdown.hidden {
    display: none !important;
    /* Force hide */
}

/* Search Bar */
.font-search-container {
    padding: 10px 12px;
    border-bottom: 1px solid var(--toolbar-border);
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    /* Slight gray for search area */
}

.font-search-container i {
    color: #64748b;
    /* Muted slate */
    font-size: 1rem;
}

#font-search-input {
    width: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 0.95rem;
    color: #1e293b;
    padding: 0;
    height: auto;
}

#font-search-input::placeholder {
    color: #94a3b8;
}

/* Font Options List */
.font-options {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: #ffffff;
}

.font-option {
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 6px;
    color: #1e293b;
    /* Ensure readability */
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    transition: background 0.1s;
    background: transparent;
}

.font-option:hover {
    background: #f1f5f9;
}

.font-option.selected {
    background: #e0e7ff;
    /* Primary soft */
    color: #4f46e5;
    /* Primary */
}

/* Scrollbar for font list */
.font-options::-webkit-scrollbar {
    width: 6px;
}

.font-options::-webkit-scrollbar-track {
    background: transparent;
}

.font-options::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}


/* --- Page Delete Button --- */
.btn-delete-page {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.btn-delete-page:hover {
    background: #dc2626;
    transform: scale(1.1);
}

.resume-page:hover .btn-delete-page {
    opacity: 1;
}


/* --- PRINT / PDF EXPORT STYLES --- */
@media print {
    /* Rules when using the DOM Isolation Strategy (printing-mode class) */

    /* 1. Hide the entire App Container */
    body.printing-mode .app-container {
        display: none !important;
    }

    /* 2. Style the Cloned Print Container */
    body.printing-mode .print-area {
        display: block !important;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        background: white;
    }

    /* 3. Style Pages within the clone */
    body.printing-mode .resume-page {
        margin: 0 !important;
        box-shadow: none !important;
        border: none !important;
        /* Exact A4 dimensions to preventing overflow */
        width: 210mm !important;
        height: 296mm !important;
        /* Safety buffer */
        overflow: hidden !important;
        page-break-after: always;
        break-after: page;
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }

    /* Remove break from last page */
    body.printing-mode .resume-page:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
    }

    /* Fallback: If printing-mode fails, hide UI elements manually (Legacy support) */
    .sidebar,
    .top-bar,
    .controls-panel,
    .floating-toolbar,
    .resize-handle,
    .control-handle,
    ::-webkit-scrollbar {
        display: none !important;
    }

    /* General Cleanups */
    @page {
        size: A4;
        margin: 0;
    }

    body {
        margin: 0;
        background: white;
    }
}

/* Progress Bar Styles */
.progress-presets {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-preview-btn {
    background: var(--bg-tertiary);
    /* fallback if var not def, acts transparentish */
    background: #1e293b;
    /* manual fallback matching sidebar-bg */
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.75rem;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.progress-preview-btn:hover {
    background: var(--input-bg);
    border-color: var(--primary-color);
}

.progress-preview-btn::after {
    content: '';
    width: 60px;
    height: 6px;
    background: linear-gradient(to right, var(--primary-color) 50%, var(--border-color) 50%);
    border-radius: 4px;
}

/* Canvas Progress Bar Element */
.element-progressbar {
    border: 1px dashed transparent;
    /* For selection state */
    display: flex;
    flex-direction: column;
}

.element-progressbar.selected {
    border-color: var(--primary-color);
}

.pg-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: #e2e8f0;
    /* Default BG */
}

.pg-fill {
    height: 100%;
    background-color: #3b82f6;
    /* Default Fill */
    width: 50%;
    transition: width 0.3s ease;
}

/* Preset Styles */
.pg-rounded .pg-container,
.pg-rounded .pg-fill {
    border-radius: 999px;
}

.pg-striped .pg-fill {
    background-image: linear-gradient(45deg, rgba(255, 255, 255, .15) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
}


/* Sidebar Config Styles */
.form-group-sm {
    margin-bottom: 0.8rem;
}

.form-group-sm label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.sidebar-select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.4rem;
    border-radius: 4px;
}

.sidebar-range {
    width: 100%;
    cursor: pointer;
}

.color-input-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.color-input-wrapper input[type='color'] {
    border: none;
    background: none;
    width: 24px;
    height: 24px;
    padding: 0;
    cursor: pointer;
}

.full-width {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* --- Header Buttons --- */
.btn-primary,
.btn-secondary {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-size: 0.9rem;
    border: none;
    text-decoration: none;
    /* In case of links */
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}