/* CV Builder Professional - Stylesheet */
/* Author: CV Builder Team | Production Ready */

body {
    font-family: 'Sarabun', sans-serif;
    background: #f3f4f6;
}

/* === A4 PRINT SETTINGS === */
@page {
    size: A4;
    margin: 15mm 20mm;
}

@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        width: 100% !important;
        height: auto !important;
    }

    .no-print {
        display: none !important;
    }

    .lg\:col-span-5,
    nav,
    header,
    .top-bar {
        display: none !important;
    }

    .lg\:col-span-7 {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        min-height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        padding: 0 !important;
        margin: 0 !important;
        background: transparent !important;
    }

    .lg\:grid-cols-12 {
        display: block !important;
    }

    .container {
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    .cv-page,
    #cvPreview {
        position: static !important;
        width: 100% !important;
        min-height: auto !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        background: white !important;
    }

    .page-separator {
        display: none !important;
    }

    .cv-item,
    .cv-section {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    h2,
    h3,
    .year-header {
        page-break-after: avoid;
        break-after: avoid;
    }

    .page-break-section {
        page-break-before: always !important;
        break-before: always !important;
        border-top: none !important;
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    .page-break-section::before {
        display: none !important;
    }
}

/* === PAGE BREAK VISUAL INDICATOR === */
.page-break-section {
    position: relative;
    border-top: 3px solid #8b5cf6;
    padding-top: 1rem;
    margin-top: 2rem;
}

.page-break-section::before {
    content: "📄 ขึ้นหน้าใหม่";
    position: absolute;
    top: -14px;
    left: 0;
    font-size: 11px;
    font-weight: 600;
    color: #8b5cf6;
    background: white;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid #8b5cf6;
}

/* === SCROLLBAR === */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* === FORM INPUTS === */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #4A5568;
    box-shadow: 0 0 0 2px rgba(74, 85, 104, 0.2);
}

/* Increase font size for better readability */
input[type="text"],
input[type="email"],
input[type="tel"],
textarea,
select {
    font-size: 15px !important;
    line-height: 1.5;
}

/* Auto-resize textarea */
textarea {
    resize: vertical;
    min-height: 38px;
    overflow-y: hidden;
}

/* Label styles */
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.dark label {
    color: #d1d5db;
}

/* === CV PAGE PREVIEW === */
.cv-page {
    width: 210mm;
    min-height: auto;
    background: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    margin: 0 auto 20px auto;
    /* เพิ่ม margin-bottom เพื่อเว้นระยะระหว่างหน้า */
    padding: 15mm 20mm;
    position: relative;
    page-break-after: always;
}

/* แสดง page indicator ระหว่างหน้า (เฉพาะ preview) */
.cv-page::after {
    content: '';
    display: block;
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 1px;
    background: linear-gradient(to right, transparent, #cbd5e0, transparent);
}

/* ซ่อน indicator ของหน้าสุดท้าย */
.cv-page:last-child::after {
    display: none;
}


.cv-section {
    margin-bottom: 1.5rem;
}

.cv-item {
    margin-bottom: 0.75rem;
}

.year-header {
    display: block;
}

/* === PAGE SEPARATOR === */
.page-separator {
    position: relative;
    width: calc(100% + 40mm);
    margin-left: -20mm;
    margin-right: -20mm;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 0;
    margin-bottom: 0;
}

.page-separator .margin-bottom-area {
    width: 100%;
    height: 15mm;
    background: white;
}

.page-separator .gap-area {
    width: 100%;
    height: 20px;
    background: rgba(229, 231, 235, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.page-separator .gap-area::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 0;
    border-top: 2px dashed rgba(99, 102, 241, 0.4);
}

.page-separator .page-badge {
    position: relative;
    font-size: 11px;
    font-weight: 600;
    color: #4338ca;
    background: #eef2ff;
    padding: 3px 12px;
    border-radius: 9999px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.35);
    white-space: nowrap;
    z-index: 1;
}

.page-separator .margin-top-area {
    width: 100%;
    height: 15mm;
    background: white;
}

.page-separator-spacer {
    display: none !important;
}

/* === UTILITIES === */
.btn-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === MODAL STYLES === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 12px;
}

.modal-input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    transition: border-color 0.2s;
}

.modal-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.modal-btn-cancel {
    background: #f3f4f6;
    color: #4b5563;
}

.modal-btn-cancel:hover {
    background: #e5e7eb;
}

.modal-btn-confirm {
    background: #3b82f6;
    color: white;
}

.modal-btn-confirm:hover {
    background: #2563eb;
}

.modal-btn-danger {
    background: #ef4444;
    color: white;
}

.modal-btn-danger:hover {
    background: #dc2626;
}

/* === SECTION TYPE SELECTOR === */
.section-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.section-type-btn {
    padding: 12px 8px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    font-size: 13px;
}

.section-type-btn:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.section-type-btn.selected {
    border-color: #3b82f6;
    background: #3b82f6;
    color: white;
}

.section-type-btn i {
    display: block;
    font-size: 20px;
    margin-bottom: 4px;
}

/* === DARK MODE SUPPORT === */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --accent-color: #3b82f6;
}

.dark {
    /* Dark blue theme inspired by modern dashboards */
    --bg-primary: #1e2139;
    --bg-secondary: #151929;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --border-color: #2d3250;
    --accent-color: #3b82f6;
}

body {
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
}

/* Dark mode overrides */
.dark .bg-white {
    background-color: var(--bg-primary) !important;
}

.dark .text-gray-900 {
    color: var(--text-primary) !important;
}

.dark .text-gray-700 {
    color: var(--text-secondary) !important;
}

.dark .text-gray-600 {
    color: #9ca3af !important;
}

.dark .border-gray-200 {
    border-color: var(--border-color) !important;
}

.dark .border-gray-800 {
    border-color: #6b7280 !important;
}

/* Dark mode for CV preview (keep it white for print) */
.dark .cv-page {
    background: white !important;
    color: #1f2937 !important;
}

/* Force preview area to stay white */
.dark #cvPreview {
    background: white !important;
}

.dark .cv-page * {
    color: inherit !important;
}


/* Dark mode for modals */
.dark .modal-box {
    background: #1e2139;
    color: #e5e7eb;
    border: 1px solid #2d3250;
}

.dark .modal-title {
    color: #e5e7eb;
}

.dark .modal-input {
    background: #252b47;
    border-color: #2d3250;
    color: #e5e7eb;
}

.dark .section-type-btn {
    background: #252b47;
    border-color: #2d3250;
    color: #e5e7eb;
}

.dark .section-type-btn:hover {
    background: #2d3250;
    border-color: #3b82f6;
}

.dark .section-type-btn.selected {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* === AUTO-SAVE INDICATOR === */
.auto-save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border: 2px solid #e5e7eb;
    color: #374151;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    z-index: 9999;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    gap: 8px;
}

.auto-save-indicator.show {
    opacity: 1;
    transform: translateY(0);
}

.auto-save-indicator.saving {
    border-color: #3b82f6;
    background: #eff6ff;
    color: #1e40af;
}

.auto-save-indicator.saved {
    border-color: #10b981;
    background: #d1fae5;
    color: #065f46;
}

.auto-save-indicator.error {
    border-color: #ef4444;
    background: #fee2e2;
    color: #991b1b;
}

.dark .auto-save-indicator {
    background: #1e2139;
    border-color: #2d3250;
    color: #e5e7eb;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.auto-save-indicator .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* === ACCESSIBILITY === */
.skip-to-main {
    position: absolute;
    left: -9999px;
    z-index: 999;
    padding: 1rem;
    background: #3b82f6;
    color: white;
    text-decoration: none;
    border-radius: 4px;
}

.skip-to-main:focus {
    left: 1rem;
    top: 1rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus styles for keyboard navigation */
button:focus,
input:focus,
textarea:focus,
select:focus {
    outline: 3px solid #3b82f6;
    outline-offset: 2px;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .auto-save-indicator {
        bottom: 10px;
        right: 10px;
        font-size: 11px;
        padding: 8px 12px;
    }

    button,
    a,
    input,
    select {
        min-height: 44px;
    }
}

@media (max-width: 640px) {
    .cv-page {
        width: 100% !important;
        padding: 10mm 15mm !important;
    }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* === DARK MODE ENHANCEMENTS FOR EDITOR === */
.dark input[type="text"],
.dark input[type="email"],
.dark input[type="tel"],
.dark textarea,
.dark select {
    background-color: #252b47 !important;
    border-color: #2d3250 !important;
    color: #e5e7eb !important;
}

.dark input[type="text"]:focus,
.dark input[type="email"]:focus,
.dark input[type="tel"]:focus,
.dark textarea:focus,
.dark select:focus {
    background-color: #2d3250 !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2) !important;
}

.dark input::placeholder,
.dark textarea::placeholder {
    color: #9ca3af;
}

/* Dark mode for Personal Info section */
.dark .bg-blue-50 {
    background-color: #1a2038 !important;
}

.dark .border-blue-100 {
    border-color: #2d3250 !important;
}

.dark .text-blue-800 {
    color: #60a5fa !important;
}

.dark .text-blue-600 {
    color: #3b82f6 !important;
}

.dark .border-blue-200 {
    border-color: #2d3250 !important;
}

/* Dark mode for Section headers */
.dark .bg-gradient-to-r {
    background: linear-gradient(to right, #1a2038, #1e2139) !important;
}

.dark .border-l-blue-500 {
    border-left-color: #3b82f6 !important;
}

.dark .border-blue-100 {
    border-color: #2d3250 !important;
}

/* Dark mode for button backgrounds in sections */
.dark button.bg-white {
    background-color: #252b47 !important;
    color: #e5e7eb !important;
    border-color: #2d3250 !important;
}

.dark button.bg-white:hover {
    background-color: #2d3250 !important;
}

.dark button.border {
    border-color: #2d3250 !important;
}

/* Remove white borders in dark mode */
.dark .border-white {
    border-color: #2d3250 !important;
}

.dark .border-gray-100 {
    border-color: #252b47 !important;
}

.dark .border-gray-300 {
    border-color: #2d3250 !important;
}

.dark .border-gray-200 {
    border-color: #2d3250 !important;
}

.dark .border-gray-600 {
    border-color: #2d3250 !important;
}

.dark .border-gray-700 {
    border-color: #2d3250 !important;
}

/* Dark mode for specific button types */
.dark .bg-amber-50 {
    background-color: #42341a !important;
}

.dark .border-amber-200 {
    border-color: #92400e !important;
}

.dark .text-amber-700 {
    color: #fbbf24 !important;
}

.dark .bg-red-50 {
    background-color: #3a1a1a !important;
}

.dark .border-red-200 {
    border-color: #7f1d1d !important;
}

.dark .text-red-600 {
    color: #f87171 !important;
}

.dark .bg-purple-500 {
    background-color: #8b5cf6 !important;
}

/* Dark mode for section borders */
.dark .border-2 {
    border-color: #374151 !important;
}

.dark .border-l-2 {
    border-left-color: #4b5563 !important;
}

.dark .border-gray-200 {
    border-color: #374151 !important;
}

/* Dark mode for add item button */
.dark .border-dashed {
    border-color: #4b5563 !important;
    color: #9ca3af !important;
}

.dark .border-dashed:hover {
    border-color: #60a5fa !important;
    color: #60a5fa !important;
}

/* === BULLET POINTS ALIGNMENT === */
/* Fix bullet points to be vertically centered with text */
#cvPreview ul {
    list-style-position: outside;
    padding-left: 1.25rem;
    margin: 0.5rem 0;
}

#cvPreview ul li {
    position: relative;
    padding-left: 0.25rem;
    margin-bottom: 0.375rem;
    line-height: 1.6;
    display: list-item;
}

#cvPreview ul li::marker {
    content: "•";
    font-size: 1em;
    line-height: 1.6;
    vertical-align: middle;
}

/* For editor textareas - general styling */
ul {
    list-style-position: outside;
    padding-left: 1.25rem;
}


ul li {
    position: relative;
    padding-left: 0.25rem;
    margin-bottom: 0.375rem;
}

ul li::marker {
    content: "•";
    font-size: 1em;
    vertical-align: middle;
}

/* === TOAST NOTIFICATION === */
.toast-notification {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s ease-in-out;
    pointer-events: none;
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast-content {
    background: white;
    border-left: 4px solid #10b981;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 250px;
    font-weight: 500;
    color: #1f2937;
}

.dark .toast-content {
    background: #1f2937;
    color: #f3f4f6;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.toast-content i {
    font-size: 1.25rem;
}

/* === AUTO-SAVE INDICATOR === */
.auto-save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 9999px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-in-out;
    z-index: 9998;
    pointer-events: none;
}

.auto-save-indicator.show {
    opacity: 1;
    transform: translateY(0);
}

.auto-save-indicator i {
    font-size: 1rem;
}

/* === KEYBOARD SHORTCUT BADGE === */
kbd {
    font-family: 'Inter', monospace;
    font-size: 0.75rem;
    font-weight: 600;
}