/**
 * css/custom.css
 * Core Styles for Resume Hub (cv.tmsofts.in)
 * Includes CSS variables, A4 print rules, custom scrollbars, and dynamic layout bindings.
 */

/* ==========================================================================
   CSS Variables & Theming
   ========================================================================== */
:root {
    /* Primary brand color - updated via JS color picker */
    --color-primary: #2563eb; 
    
    /* Global Layout Settings - updated via JS sliders */
    --font-family-global: 'Inter', sans-serif;
    --global-font-size: 14px;
    --global-line-height: 1.5;
    --page-margins: 20mm;
    --section-spacing: 16px;
}

/* Base resets for dynamic font loading */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Custom Scrollbar Styling
   ========================================================================== */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

/* Dark mode scrollbar */
.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: #475569;
}

.dark .custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: #64748b;
}

/* ==========================================================================
   A4 Canvas & Resume Template Base Rules
   ========================================================================== */
.a4-page {
    /* Exact A4 Proportions */
    width: 210mm;
    min-height: 297mm;
    background: #ffffff;
    margin: 0 auto;
    position: relative;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    /* Prevents content from bleeding out of the canvas visual boundary */
    overflow: hidden; 
}

/* Container inside the A4 page that receives dynamic CSS variables */
#cv-template-container {
    font-family: var(--font-family-global);
    font-size: var(--global-font-size);
    line-height: var(--global-line-height);
    padding: var(--page-margins);
    color: #1f2937; /* Tailwind gray-800 */
    box-sizing: border-box;
    width: 100%;
    min-height: 100%;
}

/* Universal section spacing application */
.cv-section {
    margin-bottom: var(--section-spacing);
}
.cv-section:last-child {
    margin-bottom: 0;
}

/* Utility to hide elements specifically in the preview/PDF */
.hidden-in-preview {
    display: none !important;
}

/* ==========================================================================
   UI Components & Interactivity
   ========================================================================== */

/* Toggle Switch (RTL toggle etc.) */
input:checked + .block {
    background-color: var(--color-primary);
}

input:checked + .block + .dot {
    transform: translateX(100%);
}

/* SortableJS Drag & Drop Styling */
.sortable-ghost {
    opacity: 0.4;
    background-color: #f3f4f6;
    border: 1px dashed #9ca3af;
    border-radius: 0.5rem;
}

.dark .sortable-ghost {
    background-color: #374151;
    border-color: #6b7280;
}

.sortable-drag {
    cursor: grabbing !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.cursor-grab {
    cursor: grab;
}

/* Hide empty elements in template to prevent awkward spacing */
.cv-empty:empty {
    display: none !important;
}

/* ==========================================================================
   RTL (Right-To-Left) Support
   ========================================================================== */
[dir="rtl"] #cv-template-container {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .rtl-flip {
    transform: scaleX(-1);
}

/* ==========================================================================
   Print Media Queries (@media print)
   ========================================================================== */
@media print {
    /* Reset page settings */
    @page {
        size: A4;
        margin: 0;
    }

    /* Hide the entire app UI */
    header, 
    footer, 
    section.w-full.lg\:w-\[45\%\], /* Left Panel */
    section.w-full.xl\:w-\[40\%\], 
    .preview-toolbar, 
    #btn-generate-pdf, 
    .modal,
    #page-break-indicator { 
        display: none !important; 
    }

    /* Expand workspace to full screen for printing */
    body { 
        background: white !important; 
        margin: 0; 
        padding: 0; 
    }

    main {
        height: auto !important;
        display: block !important;
    }

    section.w-full.lg\:w-\[55\%\] { 
        width: 100% !important; 
        max-width: 100% !important; 
        background: white !important;
    }

    #preview-workspace { 
        padding: 0 !important; 
        background: transparent !important; 
        overflow: visible !important; 
        justify-content: flex-start !important;
    }

    /* Reset scale transform for strict A4 output */
    #a4-wrapper { 
        transform: scale(1) !important; 
        width: 100% !important;
    }

    /* Print specific A4 rules */
    .a4-page {
        box-shadow: none !important;
        margin: 0 !important;
        width: 210mm !important;
        /* Allow it to flow naturally to new pages */
        min-height: auto !important; 
        page-break-after: always;
    }

    /* Optional: prevent page breaks inside specific elements */
    .cv-section, .cv-item {
        page-break-inside: avoid;
    }
}
