/**
 * Star Kreditrechner – Custom Stylesheet
 *
 * All Kreditrechner-specific styles live here.
 * Tailwind utility classes are loaded via wp_enqueue_script (CDN).
 * Google Fonts (Poppins) are loaded via wp_enqueue_style.
 */

/* ── Base ──────────────────────────────────────────────────────────────── */

.star-kreditrechner-wrapper {
    font-family: 'Poppins', sans-serif;
    background-color: transparent;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.star-kreditrechner-wrapper * {
    box-sizing: border-box;
}

/* ── Range Slider ───────────────────────────────────────────────────────── */

.kc-slider {
    -webkit-appearance: none;
    height: 8px;
    border-radius: 5px;
    background: #d1d5db;
    outline: none;
    width: 100%;
}

.kc-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    transition: all 0.15s ease;
}

.kc-slider::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

.kc-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
}

.kc-slider::-moz-range-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

/* ── Cards ──────────────────────────────────────────────────────────────── */

.kc-card {
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.kc-card:hover {
    transform: translateY(-5px);
    box-shadow:
        0 10px 25px -5px rgba(59, 130, 246, 0.1),
        0 8px 10px -6px rgba(59, 130, 246, 0.1);
}

.kc-result-card {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ── Calculating overlay ────────────────────────────────────────────────── */

.kc-calculating-overlay {
    opacity: 0.6;
    pointer-events: none;
    filter: blur(2px);
    transition: all 0.2s ease;
}

/* ── Equal-height grid ──────────────────────────────────────────────────── */

.kc-equal-height-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .kc-equal-height-container {
        grid-template-columns: repeat(3, 1fr);
        grid-auto-rows: 1fr;
    }
}

/* ── Interest-rate Gauge (Zinstacho) ────────────────────────────────────── */

.kc-gauge {
    position: relative;
    width: 100%;
    height: 180px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.kc-gauge-arc {
    position: relative;
    width: 200px;
    height: 100px;
    border-top-left-radius: 100px;
    border-top-right-radius: 100px;
    background: linear-gradient(90deg, #22c55e 0%, #eab308 50%, #ef4444 100%);
    overflow: hidden;
    margin-top: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.kc-gauge-overlay {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 90px;
    border-top-left-radius: 90px;
    border-top-right-radius: 90px;
    background-color: white;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
}

.kc-gauge-needle {
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 4px;
    height: 100px;
    background-color: #1e293b;
    transform-origin: bottom center;
    transform: rotate(0deg);
    transition: transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

.kc-gauge-needle::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: -8px;
    width: 20px;
    height: 20px;
    background-color: #1e293b;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(30, 41, 59, 0.2);
}

.kc-gauge-labels {
    position: relative;
    width: 200px;
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    margin-top: 10px;
}

.kc-gauge-tick {
    position: absolute;
    bottom: 0;
    width: 2px;
    height: 10px;
    background-color: rgba(30, 41, 59, 0.3);
    transform-origin: bottom center;
}

.kc-gauge-value-bg {
    position: absolute;
    bottom: 45%;
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 70px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    z-index: 15;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.kc-gauge-value {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5rem;
    font-weight: bold;
    color: #1e293b;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    z-index: 20;
    transition: all 0.5s ease;
    padding: 10px;
}

/* ── Tooltip ────────────────────────────────────────────────────────────── */





/* ── Info button (blinking) ─────────────────────────────────────────────── */

.kc-info-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #e0f2fe;
    color: #3b82f6;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: kc-blink 1.2s infinite;
}

.kc-info-button:hover {
    background-color: #bfdbfe;
}

@keyframes kc-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ── Modal ──────────────────────────────────────────────────────────────── */

.kc-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.5);
    padding-top: 900px;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .kc-modal {
        padding-top: 0;
    }
}

.kc-modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border-radius: 8px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    width: 80%;
    max-width: 500px;
    position: relative;
}

.kc-close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.kc-close-modal:hover {
    color: #000;
    text-decoration: none;
}

.kc-modal-title {
    padding-right: 20px;
    margin-bottom: 15px;
    font-size: 1.125rem;
    font-weight: 600;
}

.kc-modal-paragraph {
    margin-bottom: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.kc-modal-paragraph:last-child {
    margin-bottom: 0;
}

/* ── CTA Button „Unverbindliche Offerte" ────────────────────────────────── */

.calculate-btn-credit-offer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 13px 22px;
    background: transparent;
    color: #ffffff;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 5px;
    font-family: 'Poppins', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    text-decoration: none !important;
    cursor: pointer;
    transition: background 0.22s ease, color 0.22s ease, border-color 0.22s ease,
                transform 0.18s ease, box-shadow 0.22s ease;
    margin-top: 1rem;
    position: relative;
}

/* Double-chevron icon via pseudo-element (replaces calculator icon) */
.calculate-btn-credit-offer .fa-calculator {
    display: none;
}

.calculate-btn-credit-offer::after {
    content: '\00BB\00BB'; /* »» */
    margin-left: 10px;
    font-size: 1rem;
    opacity: 0.9;
    transition: transform 0.2s ease;
    font-style: normal;
}

/* Hover state */
.calculate-btn-credit-offer:hover {
    background: #ffffff;
    color: #1d4ed8;
    border-color: #ffffff;
    text-decoration: none !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.calculate-btn-credit-offer:hover::after {
    transform: translateX(4px);
}

/* Fix: Button-Text immer lesbar – auch nach Klick (:visited/:focus/:active) */
.calculate-btn-credit-offer:visited {
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.85);
    background: transparent;
    text-decoration: none !important;
}
.calculate-btn-credit-offer:visited::after {
    color: #ffffff;
}
.calculate-btn-credit-offer:focus {
    color: #ffffff;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
    text-decoration: none !important;
}
.calculate-btn-credit-offer:active {
    color: #ffffff;
    transform: translateY(0);
    text-decoration: none !important;
}







/* =====================================================================
   TOOLTIP 1 – Jahreszins Inline Info
   Desktop : CSS :hover + JS centers within card
   Mobile  : JS .kc-active class → fixed, centered, NO backdrop
   ===================================================================== */
.kc-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    overflow: visible;
}

.kc-tooltip .kc-tooltip-text {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, visibility 0.18s ease;
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    width: 310px;
    background: #1e293b;
    color: #fff;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 0.83rem;
    line-height: 1.6;
    white-space: normal;
    box-shadow: 0 12px 32px rgba(0,0,0,0.28);
    text-align: left;
    box-sizing: border-box;
    z-index: 999999;
    overflow-y: auto;
    max-height: 80vh;
}

/* Close button (hidden on desktop, shown on mobile) */
.kc-tt-close {
    display: none;
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    transition: color 0.15s;
}
.kc-tt-close:hover { color: #fff; }

/* Title */
.kc-tt-title {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 8px;
    padding-right: 24px; /* space for close btn on mobile */
    border-bottom: 1px solid rgba(255,255,255,0.18);
    text-align: center;
}

/* Row layout */
.kc-tt-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.82rem;
    line-height: 1.55;
}
.kc-tt-row:last-child { margin-bottom: 0; }
.kc-tt-icon { flex-shrink: 0; font-size: 0.95rem; margin-top: 1px; }

/* Arrow at bottom (points to trigger) */
.kc-tooltip .kc-tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: var(--kc-tt-arrow, 50%);
    margin-left: -7px;
    border: 7px solid transparent;
    border-top-color: #1e293b;
}

/* ── DESKTOP: CSS hover shows tooltip ── */
@media (min-width: 768px) {
    .kc-tooltip:hover .kc-tooltip-text,
    .kc-tooltip:focus .kc-tooltip-text {
        visibility: visible;
        opacity: 1;
    }
}

/* ── MOBILE: .kc-active class → fixed, centered, NO backdrop ── */
@media (max-width: 767px) {
    /* Prevent accidental CSS-hover on touch */
    .kc-tooltip:hover .kc-tooltip-text {
        visibility: hidden !important;
        opacity: 0 !important;
    }
    /* Show on tap */
    .kc-tooltip.kc-active .kc-tooltip-text {
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        position: fixed !important;
        left: 50% !important;
        top: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: min(calc(100vw - 32px), 360px) !important;
        bottom: auto !important;
        z-index: 999999 !important;
        max-height: 75vh;
        overflow-y: auto;
    }
    /* Show close button on mobile */
    .kc-tooltip.kc-active .kc-tt-close { display: block; }
    /* No arrow on mobile */
    .kc-tooltip.kc-active .kc-tooltip-text::after { display: none !important; }
    /* NO dark backdrop — removed */
}

/* =====================================================================
   MODAL – Zinstacho Info (Tooltip 2)
   ===================================================================== */
.kc-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000000;
    background-color: rgba(0,0,0,0.52);
    overflow-y: auto;
    padding: 24px 20px;
    box-sizing: border-box;
}
@media (min-width: 768px) {
    .kc-modal {
        align-items: center;
        justify-content: center;
    }
}
@media (max-width: 767px) {
    .kc-modal { padding: 12px; }
}

.kc-modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 28px 24px;
    width: 100%;
    max-width: 500px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.22);
    box-sizing: border-box;
    flex-shrink: 0;
    margin: auto;
}
@media (max-width: 767px) {
    .kc-modal-content {
        max-width: 100%;
        border-radius: 16px;
        padding: 22px 18px;
        margin-top: 8px;
    }
}
.kc-close-modal {
    position: absolute;
    top: 14px; right: 16px;
    color: #94a3b8;
    font-size: 26px; font-weight: bold;
    background: none; border: none;
    cursor: pointer; padding: 2px 6px; line-height: 1;
    transition: color 0.15s;
}
.kc-close-modal:hover { color: #1e293b; }
.kc-modal-title {
    font-size: 1.15rem; font-weight: 700;
    margin-bottom: 20px; padding-right: 32px;
    line-height: 1.4; color: #1e293b;
}
.kc-modal-paragraph {
    font-size: 0.93rem; line-height: 1.65;
    margin-bottom: 0; color: #374151;
}
.kc-modal-paragraph:last-child { margin-bottom: 0; }
@media (max-width: 767px) {
    .kc-modal-title { font-size: 1.05rem; }
    .kc-modal-paragraph { font-size: 0.875rem; }
}

/* =====================================================================
   CTA BUTTON – Unverbindliche Offerte
   ===================================================================== */
.calculate-btn-credit-offer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 13px 22px;
    background: transparent;
    color: #fff;
    border: 2px solid rgba(255,255,255,0.85);
    border-radius: 5px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    text-decoration: none !important;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.22s, color 0.22s, border-color 0.22s,
                transform 0.18s, box-shadow 0.22s;
}
.calculate-btn-credit-offer .fa-calculator { display: none; }
.calculate-btn-credit-offer::after {
    content: '\BB\BB';
    margin-left: 10px;
    font-size: 1rem;
    transition: transform 0.2s;
}
.calculate-btn-credit-offer:hover,
.calculate-btn-credit-offer:focus {
    background: #fff;
    color: #1d4ed8;
    border-color: #fff;
    text-decoration: none !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.18);
    outline: none;
}
.calculate-btn-credit-offer:hover::after { transform: translateX(4px); }
.calculate-btn-credit-offer:visited,
.calculate-btn-credit-offer:active {
    color: #fff !important;
    border-color: rgba(255,255,255,0.85) !important;
    background: transparent !important;
    text-decoration: none !important;
}

/* =====================================================================
   MOBILE LAYOUT: Zinstacho zuerst + kompakter Tacho
   ===================================================================== */
@media (max-width: 1023px) {
    .kc-equal-height-container > *:nth-child(3) {
        order: -1 !important;
        padding: 16px !important;
    }
    .kc-gauge { height: 130px !important; }
    .kc-gauge-arc {
        width: 160px !important;
        height: 80px !important;
        border-top-left-radius: 80px !important;
        border-top-right-radius: 80px !important;
        margin-top: 10px !important;
    }
    .kc-gauge-overlay {
        width: 144px !important;
        height: 72px !important;
        border-top-left-radius: 72px !important;
        border-top-right-radius: 72px !important;
    }
    .kc-gauge-value { font-size: 1.05rem !important; }
    .kc-gauge-labels { font-size: 0.7rem !important; }
    .kc-equal-height-container > *:nth-child(3) .border-t {
        margin-top: 8px !important;
        padding-top: 8px !important;
    }
}

/* =====================================================================
   ALLE ANZEIGEN BUTTON – Desktop + Mobile, zentriert unter Raten
   ===================================================================== */
.kc-amort-header-btn    { display: none !important; }
.kc-mobile-show-all-wrap { display: none !important; }

.kc-show-all-wrap {
    display: flex;
    justify-content: center;
    padding: 16px 0 6px;
}
.kc-show-all-btn {
    color: #1d4ed8;
    border: 1.5px solid #93c5fd;
    background: #fff;
    padding: 9px 32px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    user-select: none;
    transition: background 0.15s, border-color 0.15s;
}
.kc-show-all-btn:hover,
.kc-show-all-btn:focus,
.kc-show-all-btn:active {
    color: #1d4ed8 !important;
    background: #eff6ff !important;
    border-color: #3b82f6 !important;
    opacity: 1 !important;
    outline: none !important;
}

/* Tooltip 1: nur Titel + erster Punkt sichtbar */
.kc-tooltip .kc-tooltip-text .kc-tt-row ~ .kc-tt-row {
    display: none !important;
}

/* =====================================================================
   MOBILE POLISH: Grid-Abstand, Slider & Modal-Scroll
   ===================================================================== */

/* ── 1. Grid-Gap kleiner → Zinstacho + Kreditdetails schliessen näher an ── */
@media (max-width: 1023px) {
    .kc-equal-height-container {
        gap: 0.6rem !important;
    }
}

/* ── 2. Slider: besserer Thumb-Abstand & professionellere Abstände ── */
@media (max-width: 767px) {
    /* Vertikales Padding damit der Thumb-Kreis nicht abgeschnitten wird */
    .kc-slider {
        padding: 10px 0 !important;
        height: 6px !important;
        margin-top: 8px !important;
    }

    /* Abstand zwischen Wertanzeige-Zeile und Slider vergrössern */
    .kc-card .flex.justify-between.items-center.mb-2 {
        margin-bottom: 0 !important;
    }

    /* Min/Max Labels weniger Abstand nach oben */
    .kc-card .flex.justify-between.text-xs {
        margin-top: 4px !important;
    }

    /* Abstände zwischen Slider-Sektionen (mb-6 → 18px) */
    .kc-card .mb-6 {
        margin-bottom: 18px !important;
    }

    /* Thumb-Grösse auf Mobile leicht grösser für leichtere Bedienung */
    .kc-slider::-webkit-slider-thumb {
        width: 26px !important;
        height: 26px !important;
    }
    .kc-slider::-moz-range-thumb {
        width: 26px !important;
        height: 26px !important;
    }

    /* Kreditdetails Karten-Padding oben / unten kompakter */
    .kc-equal-height-container > *:nth-child(1),
    .kc-equal-height-container > *:nth-child(2) {
        padding: 16px !important;
    }
}

/* ── 3. Zinstacho Modal: scrollbar auf Mobile ── */
@media (max-width: 767px) {
    .kc-modal {
        overflow-y: hidden !important;
    }
    .kc-modal-content {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        max-height: calc(100svh - 48px);
    }
}
