/* Print Styles for PDF Export */
@media print {

    /* Force exact A4 dimensions */
    @page {
        size: A4 portrait;
        margin: 12mm 0;
    }

    /* Reset body for print */
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
        height: auto !important;
        overflow: visible !important;
        max-height: none !important;
    }

    /* Force all containers visible */
    html,
    body,
    div,
    section,
    main {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
    }

    /* Hide non-CV elements */
    /* Only hide the page chrome. CV templates use semantic <header> elements
       for the candidate name and photo, so a global header selector would
       remove them from the generated PDF. */
    body.printing > header,
    .print\:hidden,
    button,
    [x-show="false"] {
        display: none !important;
    }

    /* Druck-Isolation: Beim Drucken wird #cv-preview von printCV() in
       #print-root (direktes <body>-Kind) verschoben. Alle anderen direkten
       Body-Kinder werden ausgeblendet (display:none -> kein Platzverbrauch,
       daher KEINE leeren Extraseiten). */
    body.printing > *:not(#print-root) {
        display: none !important;
    }

    #print-root {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Full width for CV preview - Match A4 printable area */
    #cv-preview {
        width: 210mm !important;
        max-width: 210mm !important;
        min-width: 210mm !important;
        min-height: auto !important;
        max-height: none !important;
        height: auto !important;
        margin: 0 !important;
        padding: 8mm !important;
        box-sizing: border-box !important;
        box-shadow: none !important;
        page-break-after: auto !important;
        page-break-before: auto !important;
        overflow: visible !important;
        position: relative !important;
        display: block !important;
        transform: none !important;
        transform-origin: initial !important;
    }

    /* Ensure all child elements visible */
    #cv-preview * {
        overflow: visible !important;
        max-height: none !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Keep preview cropping/rounding behavior for photos and other clipped elements */
    #cv-preview .overflow-hidden,
    #cv-preview [class*="overflow-hidden"] {
        overflow: hidden !important;
    }

    /* Timeline template: ensure photo matches preview (size, crop, round) */
    #cv-preview .timeline-wrapper img.w-48.h-48 {
        width: 12rem !important;
        height: 12rem !important;
        max-width: 12rem !important;
        max-height: 12rem !important;
        border-radius: 9999px !important;
        object-fit: cover !important;
        object-position: center !important;
        margin-left: auto !important;
        margin-right: auto !important;
        border-width: 4px !important;
        border-style: solid !important;
        border-color: #d1d5db !important;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1) !important;
        display: block !important;
    }

    /* Kategorie-Level (Balken & Punkte) im Druck/PDF erhalten.
       Sonst setzt die Regel "div { height:auto }" die feste Höhe auf 0 -> unsichtbar. */
    #cv-preview .cat-bar {
        height: 6px !important;
        border-radius: 9999px !important;
        overflow: hidden !important;
    }
    #cv-preview .cat-bar-fill {
        height: 6px !important;
        border-radius: 9999px !important;
    }
    #cv-preview .cat-dot {
        display: inline-block !important;
        width: 8px !important;
        height: 8px !important;
        border-radius: 9999px !important;
    }

    /* Timeline-Punkte (aqua + timeline Vorlagen): die Regel "body *{height:auto}"
       lässt den absolut positionierten Punkt-<span>/<div> auf Höhe 0 kollabieren
       -> Punkt verschwindet im PDF. Breite bleibt erhalten; mit aspect-ratio 1
       wird die Höhe = Breite wiederhergestellt (größenunabhängig: 10px/12px). */
    #cv-preview .tl-dot {
        aspect-ratio: 1 / 1 !important;
        border-radius: 9999px !important;
    }

    /* Force flex layouts to work in print */
    .flex {
        display: flex !important;
    }

    .flex-col {
        flex-direction: column !important;
    }

    .flex-row {
        flex-direction: row !important;
    }

    /* Preserve flex gaps */
    .gap-1 {
        gap: 0.25rem !important;
    }

    .gap-2 {
        gap: 0.5rem !important;
    }

    .gap-3 {
        gap: 0.75rem !important;
    }

    .gap-4 {
        gap: 1rem !important;
    }

    .gap-5 {
        gap: 1.25rem !important;
    }

    .gap-6 {
        gap: 1.5rem !important;
    }

    .gap-8 {
        gap: 2rem !important;
    }

    /* Preserve padding classes */
    .p-1 {
        padding: 0.25rem !important;
    }

    .p-2 {
        padding: 0.5rem !important;
    }

    .p-3 {
        padding: 0.75rem !important;
    }

    .p-4 {
        padding: 1rem !important;
    }

    .p-5 {
        padding: 1.25rem !important;
    }

    .p-6 {
        padding: 1.5rem !important;
    }

    .p-8 {
        padding: 2rem !important;
    }

    /* Preserve margin classes */
    .mb-1 {
        margin-bottom: 0.25rem !important;
    }

    .mb-2 {
        margin-bottom: 0.5rem !important;
    }

    .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mb-5 {
        margin-bottom: 1.25rem !important;
    }

    .mb-6 {
        margin-bottom: 1.5rem !important;
    }

    .mb-8 {
        margin-bottom: 2rem !important;
    }

    .mt-1 {
        margin-top: 0.25rem !important;
    }

    .mt-2 {
        margin-top: 0.5rem !important;
    }

    .mt-3 {
        margin-top: 0.75rem !important;
    }

    .mt-4 {
        margin-top: 1rem !important;
    }

    /* Text sizes */
    .text-xs {
        font-size: 0.75rem !important;
    }

    .text-sm {
        font-size: 0.875rem !important;
    }

    .text-base {
        font-size: 1rem !important;
    }

    .text-lg {
        font-size: 1.125rem !important;
    }

    .text-xl {
        font-size: 1.25rem !important;
    }

    .text-2xl {
        font-size: 1.5rem !important;
    }

    .text-3xl {
        font-size: 1.875rem !important;
    }

    .text-4xl {
        font-size: 2.25rem !important;
    }

    /* Border classes */
    .border {
        border-width: 1px !important;
    }

    .border-2 {
        border-width: 2px !important;
    }

    .border-4 {
        border-width: 4px !important;
    }

    .border-t {
        border-top-width: 1px !important;
    }

    .border-b {
        border-bottom-width: 1px !important;
    }

    .border-l {
        border-left-width: 1px !important;
    }

    .border-r {
        border-right-width: 1px !important;
    }

    .border-t-2 {
        border-top-width: 2px !important;
    }

    .border-b-2 {
        border-bottom-width: 2px !important;
    }

    .border-l-4 {
        border-left-width: 4px !important;
    }

    .border-t-8 {
        border-top-width: 8px !important;
    }

    /* Rounded corners */
    .rounded {
        border-radius: 0.25rem !important;
    }

    .rounded-lg {
        border-radius: 0.5rem !important;
    }

    .rounded-full {
        border-radius: 9999px !important;
    }

    /* Width classes */
    .w-32 {
        width: 8rem !important;
    }

    .w-40 {
        width: 10rem !important;
    }

    .w-full {
        width: 100% !important;
    }

    /* Height classes */
    .h-40 {
        height: 10rem !important;
    }

    /* Object fit */
    .object-cover {
        object-fit: cover !important;
    }

    /* Add top padding to each page */
    #cv-preview>div {
        padding-top: 0 !important;
    }

    /* Ensure space at top of new pages */
    * {
        margin-top: 0;
        padding-block-start: 0;
    }

    /* Ensure colors and backgrounds print */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Prevent page breaks inside small elements */
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        page-break-after: avoid;
        page-break-inside: avoid;
        break-after: avoid-page;
        break-inside: avoid;
    }

    /* Keep section headers with content */
    h2 {
        page-break-after: avoid !important;
        break-after: avoid-page !important;
    }

    /* Gradient headers should stay with content */
    .bg-gradient-to-r,
    .bg-gradient-to-br,
    .bg-gradient-to-bl {
        page-break-after: avoid !important;
        break-after: avoid !important;
        margin-bottom: 0 !important;
    }

    /* Header + immediate next element should stay together */
    .bg-gradient-to-r+*,
    .bg-gradient-to-r+*>* {
        page-break-before: avoid !important;
        break-before: avoid !important;
        margin-top: 0 !important;
    }

    /* Ensure grid after gradient header stays together */
    .bg-gradient-to-r+.grid {
        page-break-before: avoid !important;
        break-before: avoid-page !important;
    }

    /* Allow the main template wrapper to break across pages */
    #cv-preview>div>div {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Remove min-height from most sidebars in print, but allow stripe themes to keep it if needed */
    .w-1\/3[style*="min-height"],
    [style*="min-height: 297mm"]:not(.w-16),
    [class*="min-h-[297mm]"]:not(.w-16) {
        min-height: auto !important;
        height: auto !important;
    }

    /* Dedicated rule for sidebar stripe theme */
    #cv-preview .sidebar-wrapper .w-16 {
        min-height: 260mm !important;
        /* Slightly less than A4 to account for margins */
        height: auto !important;
    }

    /* Allow flex layouts to split across pages to avoid blank first page */
    .flex {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Seitenränder: oben/unten 12mm Atemraum (damit mehrseitige Lebensläufe
       auf Folgeseiten nicht am oberen Rand kleben). Links/rechts 0, damit
       randlose Kopf-/Seitenleisten weiter bis zum Rand reichen. Die ERSTE
       Seite oben 0, damit randlose Kopfzeilen oben bündig bleiben. */
    @page {
        size: A4 portrait;
        margin: 12mm 0;
    }

    @page :first {
        margin-top: 0;
    }

    /* Creative wrapper: header + grid together - MUST fit on page */
    .creative-wrapper {
        page-break-inside: auto !important;
        break-inside: auto !important;
        display: block !important;
    }

    /* Creative header must not break from grid */
    .creative-wrapper>.bg-gradient-to-r {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    /* Small items should not break */
    .experience-item,
    .education-item,
    .skill-item {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Sections with headers should try to stay together */
    div[class*="mb-6"],
    div[class*="mb-8"] {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Kategorie-Blöcke (Sprachen, Software, Zertifikate …) NICHT über den
       Seitenumbruch zerreißen: Überschrift + Inhalt bleiben zusammen. Sonst
       steht z. B. „Fähigkeiten“ unten auf Seite 1 und die Chips auf Seite 2.
       Überschreibt bewusst die mb-6/mb-8-auto-Regel oben (höhere Spezifität). */
    #cv-preview .cat-block {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    #cv-preview .cat-heading {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    /* Einzelne Einträge (ein Job, eine Ausbildung) NICHT mitten im Eintrag
       umbrechen. Der Abschnitt selbst darf weiter über Seiten fließen – nur
       der einzelne Eintrag bleibt als Block zusammen und rutscht ggf. komplett
       auf die nächste Seite. */
    #cv-preview .cv-entry {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* Add top margin to content that starts a new page */
    div[class*="mb-6"]::before,
    div[class*="mb-8"]::before {
        content: '';
        display: block;
        height: 0;
        margin-top: 0;
    }

    /* Force top spacing on new pages */
    h2 {
        margin-top: 0;
        padding-top: 0;
    }

    /* Allow breaks in very long sections */
    .experience-list,
    .education-list {
        page-break-inside: auto;
        break-inside: auto;
    }

    /* Allow natural page breaks for sections */
    div[class*="mb-4"] {
        page-break-inside: auto;
        break-inside: auto;
    }

    /* Tables flow naturally */
    table {
        page-break-inside: auto;
        break-inside: auto;
    }

    table tr {
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Ensure content flows across pages */
    body,
    html {
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }

    /* Remove all height restrictions */
    .flex,
    .w-1\/2,
    [style*="height"] {
        height: auto !important;
        max-height: none !important;
    }

    /* Orphans and widows control */
    p,
    li {
        orphans: 3;
        widows: 3;
    }

    /* Headers need high orphans to stay with content */
    .bg-gradient-to-r {
        orphans: 10 !important;
        widows: 10 !important;
    }

    /* Force white background */
    html,
    body {
        background: white !important;
    }

    /* Hide scrollbars */
    ::-webkit-scrollbar {
        display: none;
    }

    /* Journey template: allow flex container to break across pages */
    #cv-preview>.journey-wrapper>div,
    #cv-preview>.journey-wrapper .flex,
    #cv-preview>.journey-wrapper .flex-1,
    #cv-preview>.journey-wrapper .flex * {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Override generic rule that keeps second-level wrappers together */
    #cv-preview>.journey-wrapper>div {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Journey print layout: match screen (two columns with flex) */
    #cv-preview .journey-wrapper .flex {
        display: flex !important;
        gap: 1.5rem !important;
    }

    #cv-preview .journey-wrapper .w-1\/3 {
        position: static !important;
        min-height: auto !important;
        height: auto !important;
        overflow: visible !important;
    }

    #cv-preview .journey-wrapper .flex-1 {
        margin: 0 !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
        padding-top: 10mm !important;
        /* sayfa kırımı sonrası üst boşluk */
    }

    /* Journey: içerik bloklarına üst boşluk, ilk bloğu hariç tut */
    #cv-preview .journey-wrapper .flex-1>* {
        padding-top: 6mm !important;
    }

    #cv-preview .journey-wrapper .flex-1>*:first-child {
        padding-top: 0 !important;
    }

    /* Personal data section: compact spacing in print */
    #cv-preview .mb-6,
    #cv-preview .mb-8 {
        margin-bottom: 1rem !important;
    }

    /* Reduce spacing between personal info items */
    #cv-preview .mb-2 {
        margin-bottom: 0.25rem !important;
    }

    #cv-preview .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    #cv-preview .mb-4 {
        margin-bottom: 0.75rem !important;
    }

    /* Timeline template: reduce excessive spacing in PDF */
    #cv-preview .relative.mb-6 {
        margin-bottom: 0.5rem !important;
    }

    /* Timeline template: compact section headers */
    #cv-preview .mb-4 {
        margin-bottom: 0.5rem !important;
    }

    /* Timeline template: reduce padding in content boxes */
    #cv-preview .p-4 {
        padding: 0.5rem !important;
    }

    /* Timeline template: reduce left padding for timeline items */
    #cv-preview .pl-12 {
        padding-left: 2rem !important;
    }

    #cv-preview .pl-6 {
        padding-left: 1rem !important;
    }

    /* Timeline template: ensure vertical line and dots are visible in PDF */
    #cv-preview .absolute.w-0\.5,
    #cv-preview .absolute.w-0 {
        background-color: #9ca3af !important;
        width: 2px !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    #cv-preview .absolute.w-3.h-3 {
        background-color: #111827 !important;
        width: 12px !important;
        height: 12px !important;
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
        border-radius: 50% !important;
        display: block !important;
        position: absolute !important;
    }

    /* Timeline template: extra compact spacing to prevent page break */
    #cv-preview .pl-15 {
        padding-left: 1rem !important;
    }

    /* Timeline: reduce header icon size */
    #cv-preview .w-12.h-12 {
        width: 2rem !important;
        height: 2rem !important;
    }

    /* Timeline: compact all margin-bottom in right content */
    #cv-preview .flex-1.p-8 {
        padding: 1rem !important;
    }

    /* Timeline: reduce gap between header icon and title */
    #cv-preview .gap-3 {
        gap: 0.5rem !important;
    }

    /* Timeline: reduce mb-8 sections */
    #cv-preview .mb-8 {
        margin-bottom: 1rem !important;
    }

    /* Timeline: reduce mb-6 items */
    #cv-preview .relative.mb-6.pl-6 {
        margin-bottom: 0.75rem !important;
    }

    /* Timeline: reduce card padding */
    #cv-preview .bg-white.p-4.rounded-lg.shadow {
        padding: 0.75rem !important;
    }

    /* Lebenslauf template: reduce mb-8 sections */
    #cv-preview .mb-8:not(.journey-wrapper *):not(.timeline *) {
        margin-bottom: 1rem !important;
    }

    /* Sidebar template: reduce padding and margins */
    #cv-preview .pl-8.pr-8 {
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    #cv-preview .mb-6 {
        margin-bottom: 0.75rem !important;
    }

    /* Remove min-height from sidebars in PDF to prevent gaps */
    #cv-preview [style*="min-height"] {
        min-height: auto !important;
    }

    /* Remove Tailwind min-h-[297mm] in print to prevent blank first page */
    #cv-preview .min-h-\[297mm\],
    #cv-preview [class*="min-h-[297mm]"] {
        min-height: auto !important;
    }

    /* Avoid gray background on empty space at the bottom of printed pages */
    #cv-preview .bg-slate-50.min-h-\[297mm\],
    #cv-preview .bg-gray-100.min-h-\[297mm\],
    #cv-preview .bg-gray-200.min-h-\[297mm\],
    #cv-preview .bg-slate-50[style*="min-height: 297mm"],
    #cv-preview .bg-gray-100[style*="min-height: 297mm"],
    #cv-preview .bg-gray-200[style*="min-height: 297mm"] {
        background: white !important;
    }

    /* If the root wrapper is a light gray background, force it to white in print */
    #cv-preview > div.bg-slate-50,
    #cv-preview > div.bg-gray-100,
    #cv-preview > div.bg-gray-200 {
        background: white !important;
    }

    /* Normalize light gray backgrounds to white in print (avoid gray empty areas) */
    #cv-preview [class*="bg-slate-50"],
    #cv-preview [class*="bg-slate-100"],
    #cv-preview [class*="bg-slate-200"],
    #cv-preview [class*="bg-gray-50"],
    #cv-preview [class*="bg-gray-100"],
    #cv-preview [class*="bg-gray-200"] {
        background: white !important;
    }

    /* Force template root wrapper to white in print (keeps inner colored blocks intact) */
    #cv-preview > div > :first-child:not([style*="linear-gradient"]) {
        background: white !important;
    }

    /* Reduce forced page-break avoidance to prevent extra blank pages */
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        page-break-after: auto !important;
        page-break-inside: auto !important;
        break-after: auto !important;
        break-inside: auto !important;
    }

    .bg-gradient-to-r,
    .bg-gradient-to-br,
    .bg-gradient-to-bl {
        page-break-after: auto !important;
        break-after: auto !important;
    }

    .bg-gradient-to-r+*,
    .bg-gradient-to-r+*>*,
    .bg-gradient-to-r+.grid {
        page-break-before: auto !important;
        break-before: auto !important;
    }

    .experience-item,
    .education-item,
    .skill-item,
    table tr {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Ensure flex containers stretch properly */
    #cv-preview .flex {
        align-items: flex-start !important;
    }

    /* Timeline and sidebar templates: ensure left sidebar doesn't create gaps */
    #cv-preview .w-1\/3,
    #cv-preview .w-16 {
        flex-shrink: 0 !important;
        height: auto !important;
    }

    /* Diagonal template: reduce header and spacing for PDF */
    #cv-preview .pt-8.pb-12 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    /* Diagonal: reduce gradient background height */
    #cv-preview .h-64 {
        height: 8rem !important;
    }

    /* Diagonal: compact personal data box */
    #cv-preview .rounded-lg.shadow-md.p-4 {
        padding: 0.75rem !important;
        margin-top: 0.5rem !important;
    }

    /* Diagonal: reduce mb-6 to prevent large gaps */
    #cv-preview .mb-6 {
        margin-bottom: 0.75rem !important;
    }

    /* Diagonal: reduce mb-5 spacing */
    #cv-preview .mb-5 {
        margin-bottom: 0.5rem !important;
    }

    /* ProfPlus template: reduce gradient header padding */
    #cv-preview .bg-gradient-to-r.px-8.py-6 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    /* ProfPlus: reduce main content padding */
    #cv-preview .px-8.py-6:not(.bg-gradient-to-r) {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
        padding-left: 1.5rem !important;
        padding-right: 1.5rem !important;
    }

    /* Corporate template: reduce blue gradient header */
    #cv-preview .bg-gradient-to-r.from-blue-900 {
        padding: 1rem 1.5rem !important;
    }

    /* Creative template: reduce gradient header */
    #cv-preview .bg-gradient-to-r.from-pink-500.p-4 {
        padding: 0.75rem !important;
    }

    /* Artistic template: reduce gradient header */
    #cv-preview .bg-gradient-to-br.from-teal-500.p-6 {
        padding: 1rem !important;
    }

    /* Bold template: reduce black header */
    #cv-preview .bg-black.text-white.p-6.mb-6 {
        padding: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* All templates: reduce large padding for print */
    #cv-preview .p-8,
    #cv-preview .p-10 {
        padding: 1rem !important;
    }

    /* All templates: reduce large gaps */
    #cv-preview .gap-8 {
        gap: 1rem !important;
    }

    #cv-preview .gap-6 {
        gap: 0.75rem !important;
    }

    /* All templates: compact space-y utilities */
    #cv-preview .space-y-6>*+* {
        margin-top: 0.75rem !important;
    }

    #cv-preview .space-y-8>*+* {
        margin-top: 1rem !important;
    }

    #cv-preview .space-y-4>*+* {
        margin-top: 0.5rem !important;
    }

    #cv-preview .space-y-5>*+* {
        margin-top: 0.75rem !important;
    }

    /* Reduce header and title spacing */
    #cv-preview h1,
    #cv-preview h2,
    #cv-preview h3 {
        margin-bottom: 0.5rem !important;
    }

    /* Compact section spacing for better PDF layout */
    #cv-preview>div>div {
        margin-bottom: 0.75rem !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Compact grid spacing for personal info */
    #cv-preview .grid {
        gap: 0.5rem !important;
    }

    /* Reduce photo container size slightly in print, but keep it substantial */
    #cv-preview img[class*="w-32"],
    #cv-preview .w-32.h-40 {
        max-height: none !important;
    }

    #cv-preview img[class*="w-40"],
    #cv-preview .w-40.h-48 {
        max-height: none !important;
    }

    /* Compact text in personal section */
    #cv-preview .text-sm {
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
    }

}

/* Timeline: compact all margin-bottom in right content */
#cv-preview .flex-1.p-8 {
    padding: 1rem !important;
}

/* Transitions for Alpine.js */
[x-cloak] {
    display: none !important;
}

/* Accordion animations */
[x-transition] {
    transition: all 0.3s ease;
}

/* Form focus styles */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #3b82f6;
    ring: 2px;
    ring-color: #3b82f6;
}

/* Hover effects */
button:hover {
    transform: translateY(-1px);
    transition: all 0.2s;
}

button:active {
    transform: translateY(0);
}

/* Alert animations */
@keyframes slideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

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

.alert {
    animation: slideIn 0.3s ease;
}

/* Loading spinner (if needed) */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* German date format helper */
.date-input::placeholder {
    font-size: 0.875rem;
    color: #9ca3af;
}

/* Screen: keep A4 preview centered with padding */
#cv-preview {
    width: 210mm;
    max-width: 210mm;
    min-height: 297mm;
    margin: 0;
    padding: 15mm;
    box-sizing: border-box;
}

/* Lange, umbruchlose Tokens (vor allem E-Mail-Adressen) dürfen in schmalen
   Sidebars NICHT herauslaufen oder abgeschnitten werden, sondern müssen umbrechen.
   Gilt für Bildschirm-Vorschau UND PDF (style.css wird in api/pdf.php eingebettet).
   Bewusst "break-word" (NICHT "anywhere") + KEIN globales min-width:0 – damit nur
   zu lange Wörter brechen und normale Wörter wie „Muttersprache“ in schmalen
   Spalten heil bleiben. Grid-Sonderfälle (z. B. executive) lösen das lokal. */
#cv-preview,
#cv-preview * {
    overflow-wrap: break-word;
}

/* Responsive adjustments */
@media screen and (max-width: 1024px) {

    /* Mobile: stack form and preview vertically */
    #cv-preview {
        width: 210mm !important;
        padding: 15mm !important;
        transform: scale(0.5);
        transform-origin: top center;
        margin-left: auto !important;
        margin-right: auto !important;
        margin-bottom: 100px !important;
    }

    /* Better touch targets for mobile */
    button {
        min-height: 44px;
    }

    /* Accordion buttons more touch-friendly */
    [x-show] button {
        padding-top: 0.875rem !important;
        padding-bottom: 0.875rem !important;
    }
}

@media screen and (max-width: 768px) {

    /* Keep A4 format, just scale down more */
    #cv-preview {
        width: 210mm !important;
        min-width: 210mm !important;
        padding: 15mm !important;
        transform: scale(0.4);
        transform-origin: top center;
        margin-left: auto !important;
        margin-right: auto !important;
        margin-bottom: 80px !important;
        min-height: auto !important;
    }

    /* Smaller template selector buttons */
    .grid button {
        padding: 0.5rem !important;
        font-size: 0.75rem !important;
    }
}

@media screen and (max-width: 480px) {

    /* Extra small screens - scale down but keep A4 format */
    #cv-preview {
        width: 210mm !important;
        min-width: 210mm !important;
        padding: 15mm !important;
        transform: scale(0.35);
        transform-origin: top center;
        margin-left: auto !important;
        margin-right: auto !important;
        margin-bottom: 60px !important;
    }
}

/* Template-specific print adjustments */
@media print {

    .bg-blue-900,
    .bg-blue-700,
    .bg-blue-800,
    .bg-black,
    .bg-purple-600,
    .bg-gray-700,
    .bg-gray-600,
    .bg-gray-800,
    .bg-pink-500,
    .bg-pink-600,
    .bg-orange-400,
    .bg-orange-600,
    .bg-gradient-to-r,
    .bg-gradient-to-br,
    .bg-gradient-to-bl,
    [class*="bg-gradient"],
    [class*="from-"],
    [class*="to-"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Ensure borders print */
    .border,
    .border-l-4,
    .border-b-2,
    .border-t-8,
    [class*="border-"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Preserve background colors */
    [class*="bg-"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Preserve text colors */
    [class*="text-"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Preserve clip-path for diagonal template */
    [style*="clip-path"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Preserve shadows */
    [class*="shadow"] {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    /* Fix negative margins in print */
    [class*="-m-"],
    [style*="-m-"] {
        margin: 0 !important;
    }

    /* Fix specific negative margin classes */
    .-m-20 {
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Ensure Creative template header visible */
    .bg-gradient-to-r {
        margin: 0 !important;
        padding: 1.5rem !important;
    }

    /* Reset overflow for print */
    * {
        overflow: visible !important;
    }

    /* Ensure all content visible */
    body * {
        max-height: none !important;
        height: auto !important;
    }

    /* === FOTO-FIX =========================================================
       Die Regel "body * { height:auto }" oben lässt Profilbilder auf ihre
       Eigenhöhe kollabieren -> weißer Streifen unter dem Foto, Rahmen sitzt
       nicht bündig, Hochformat wird quadratisch. Hier die festen Bildhöhen im
       Druck wiederherstellen – für das <img> selbst (z. B. w-24 h-24) UND für
       Container, die ein <img> umschließen (img dann mit h-full). object-cover
       sorgt für sauberen Beschnitt, identisch zur Bildschirm-Vorschau. */
    #cv-preview img.h-full {
        height: 100% !important;
        max-height: 100% !important;
        width: 100% !important;
        object-fit: cover !important;
    }
    #cv-preview img.h-16,  #cv-preview .h-16:has(> img)  { height: 4rem  !important; max-height: 4rem  !important; }
    #cv-preview img.h-20,  #cv-preview .h-20:has(> img)  { height: 5rem  !important; max-height: 5rem  !important; }
    #cv-preview img.h-24,  #cv-preview .h-24:has(> img)  { height: 6rem  !important; max-height: 6rem  !important; }
    #cv-preview img.h-28,  #cv-preview .h-28:has(> img)  { height: 7rem  !important; max-height: 7rem  !important; }
    #cv-preview img.h-32,  #cv-preview .h-32:has(> img)  { height: 8rem  !important; max-height: 8rem  !important; }
    #cv-preview img.h-36,  #cv-preview .h-36:has(> img)  { height: 9rem  !important; max-height: 9rem  !important; }
    #cv-preview img.h-40,  #cv-preview .h-40:has(> img)  { height: 10rem !important; max-height: 10rem !important; }
    #cv-preview img.h-44,  #cv-preview .h-44:has(> img)  { height: 11rem !important; max-height: 11rem !important; }
    #cv-preview img.h-48,  #cv-preview .h-48:has(> img)  { height: 12rem !important; max-height: 12rem !important; }
    #cv-preview img.h-56,  #cv-preview .h-56:has(> img)  { height: 14rem !important; max-height: 14rem !important; }
    #cv-preview img.h-64,  #cv-preview .h-64:has(> img)  { height: 16rem !important; max-height: 16rem !important; }
    /* Bild füllt einen fixierten Container immer komplett (Breite + Beschnitt) */
    #cv-preview [class*="overflow-hidden"] > img,
    #cv-preview [class*="rounded-full"] > img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    /* Force grid layouts to display */
    .grid {
        display: grid !important;
    }

    /* Specific grid column classes */
    .grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        display: grid !important;
    }

    /* For print: Convert 3-column grid to block layout to ensure visibility */
    @supports not (display: grid) {
        .grid-cols-3 {
            display: block !important;
        }

        .col-span-2 {
            display: block !important;
            width: 100% !important;
        }
    }

    .grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }

    .col-span-2 {
        grid-column: span 2 / span 2 !important;
        display: block !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    /* Grid immediate children can break if needed */
    .grid>div {
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    .gap-4 {
        gap: 1rem !important;
    }

    .gap-6 {
        gap: 1.5rem !important;
    }

    /* Ensure grid children visible */
    .grid>* {
        display: block !important;
        visibility: visible !important;
    }

    /* Grid first child (2/3 column) must be visible */
    .grid>.col-span-2 {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Force all template content visible - specific approach */
    #cv-preview .grid {
        display: grid !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    #cv-preview .flex {
        display: flex !important;
        page-break-inside: auto !important;
        break-inside: auto !important;
    }

    #cv-preview div,
    #cv-preview section,
    #cv-preview p,
    #cv-preview h1,
    #cv-preview h2,
    #cv-preview h3 {
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Ensure ALL grid content visible */
    #cv-preview .grid * {
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Tailwind color classes - explicit definitions for print */
    .bg-gray-50 {
        background-color: #f9fafb !important;
    }

    .bg-gray-100 {
        background-color: #f3f4f6 !important;
    }

    .bg-orange-50 {
        background-color: #fff7ed !important;
    }

    .bg-pink-50 {
        background-color: #fdf2f8 !important;
    }

    .text-orange-600 {
        color: #ea580c !important;
    }

    .text-pink-600 {
        color: #db2777 !important;
    }

    .text-gray-700 {
        color: #374151 !important;
    }

    /* Ensure body background stays white even with bg-gray-* classes */
    html,
    body,
    body[class*="bg-gray-"],
    body[class*="bg-slate-"] {
        background: white !important;
    }
}

/* Adjust Tailwind pt-16 to be 1rem smaller on screen */
.pt-16 {
    padding-top: 2rem !important;
}
/* International complete-data templates. Kept in the shared stylesheet because
   PDF export removes <style> elements from submitted CV HTML for security. */
.int-cv {
    width: 100%;
    min-height: 1123px;
    box-sizing: border-box;
    background: #fff;
    color: var(--int-ink);
    font-family: var(--int-body-font);
    font-size: 13px;
    line-height: 1.5;
}
.int-cv * { box-sizing: border-box; }
.int-cv .int-name {
    color: inherit !important;
    font-family: var(--int-font);
    font-size: 34px;
    line-height: 1.05;
    font-weight: 700;
    letter-spacing: -.025em;
}
.int-cv .int-role { font-size: 14px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; margin-top: 7px; }
.int-cv .int-photo { width: 116px; height: 138px; object-fit: cover; display: block; }
.int-cv .int-photo-round { width: 118px; height: 118px; border-radius: 999px; object-fit: cover; display: block; }
.int-cv .int-heading { font-family: var(--int-font); font-size: 14px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; margin: 0 0 13px; }
.int-cv .int-heading-line { border-bottom: 2px solid; padding-bottom: 5px; }
.int-cv .int-heading-bar { border-left: 4px solid; padding: 6px 10px; }
.int-cv .int-heading-pill { display: inline-block; padding: 5px 12px; border-radius: 999px; }
.int-cv .int-section { margin-bottom: 23px; }
.int-cv .int-about { white-space: normal; line-height: 1.65; }
.int-cv .int-entry { position: relative; margin-bottom: 17px; break-inside: avoid; page-break-inside: avoid; }
.int-cv .int-entry-top { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.int-cv .int-entry-title { font-size: 14px; font-weight: 700; }
.int-cv .int-entry-date { font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--int-muted); }
.int-cv .int-entry-meta { font-size: 12px; font-weight: 600; margin-top: 1px; }
.int-cv .int-bullets { margin: 7px 0 0; padding: 0; list-style: none; }
.int-cv .int-bullets li { position: relative; padding-left: 13px; margin: 2px 0; }
.int-cv .int-bullets li::before { content: ''; position: absolute; width: 4px; height: 4px; border-radius: 99px; background: var(--bullet); left: 1px; top: .62em; }
.int-cv .int-contact-inline { display: flex; flex-wrap: wrap; gap: 5px 16px; font-size: 10.5px; margin-top: 15px; }
.int-cv .int-contact-inline span { overflow-wrap: anywhere; }
.int-cv .int-contact-inline b { font-weight: 700; }
.int-cv .int-contact-list { display: grid; gap: 10px; }
.int-cv .int-contact-item { font-size: 11.5px; line-height: 1.4; overflow-wrap: anywhere; }
.int-cv .int-contact-label { text-transform: uppercase; letter-spacing: .08em; font-size: 9px; font-weight: 700; opacity: .7; margin-bottom: 1px; }
.int-cv .int-timeline { border-left: 1px solid color-mix(in srgb, var(--int-accent) 34%, transparent); margin-left: 5px; padding-left: 20px; }
.int-cv .int-timeline-entry::before { content: ''; position: absolute; left: -25px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--entry-accent); }
.int-cv .int-side { padding: 34px 24px; }
.int-cv .int-main { padding: 38px 40px; }
.int-cv.int-grid { display: grid; grid-template-columns: 210px 1fr; min-height: 1123px; }
.int-cv .int-side .cat-heading { color: inherit !important; }
.int-cv .int-side .cat-block { break-inside: avoid; }
.int-cv .cat-block, .int-cv .int-section { break-inside: auto; }
.int-cv .cat-heading { break-after: avoid; page-break-after: avoid; }
.int-cv .cat-bar, .int-cv .cat-dot { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
@media print {
    .int-cv { min-height: auto; }
    .int-cv.int-grid { min-height: auto; }
}
