/**
 * Wettrechner Common Styles
 *
 * @package Wettrechner
 */

/* Container */
.wettrechner-container {
    max-width: 420px;
    margin: 20px auto;
    padding: 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    box-sizing: border-box;
}

.wettrechner-container *,
.wettrechner-container *::before,
.wettrechner-container *::after {
    box-sizing: border-box;
}

/* Title */
.wettrechner-title {
    margin: 0 0 20px 0;
    padding: 0;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    color: #1a1a2e;
}

/* Form */
.wettrechner-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Field */
.wettrechner-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wettrechner-field label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
}

/* Inputs */
.wettrechner-field input,
.wettrechner-field select {
    width: 100%;
    padding: 12px 14px;
    font-size: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.wettrechner-field input:focus,
.wettrechner-field select:focus {
    outline: none;
    border-color: #4a90d9;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.wettrechner-field input::placeholder {
    color: #aaa;
}

.wettrechner-field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}

/* Tooltip */
.wettrechner-tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 13px;
    font-style: normal;
    color: #666;
    background: #f0f0f0;
    border-radius: 50%;
    cursor: help;
    position: relative;
}

.wettrechner-tooltip-icon::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 250px;
    padding: 10px 12px;
    font-size: 0.8rem;
    font-weight: 400;
    line-height: 1.4;
    color: #fff;
    background: #333;
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
    pointer-events: none;
}

.wettrechner-tooltip-icon::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1001;
}

/* Tooltip auch per Tastatur-Fokus und Antippen (Touch fokussiert
   das tabindex-Element) erreichbar, nicht nur per Maus-Hover. */
.wettrechner-tooltip-icon:hover::after,
.wettrechner-tooltip-icon:hover::before,
.wettrechner-tooltip-icon:focus::after,
.wettrechner-tooltip-icon:focus::before {
    opacity: 1;
    visibility: visible;
}

.wettrechner-tooltip-icon:focus {
    outline: 2px solid #4a90d9;
    outline-offset: 1px;
}

/* Buttons */
.wettrechner-buttons {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.wettrechner-btn {
    flex: 1;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.wettrechner-btn:active {
    transform: scale(0.98);
}

.wettrechner-btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.3);
}

.wettrechner-btn-primary:hover {
    background: linear-gradient(135deg, #5a9de0 0%, #4a90d9 100%);
    box-shadow: 0 6px 16px rgba(74, 144, 217, 0.4);
}

.wettrechner-btn-secondary {
    color: #666;
    background: #f0f0f0;
}

/* Theme-Robustheit: manche Themes (u. a. das Live-Theme der Zielsite) stylen
   button-Elemente global weiss und schlucken den Gradient über die
   background-Shorthand. Höher spezifizierte Duplikate stellen die
   Primär-/Sekundär-Hierarchie sicher. */
.wettrechner-container .wettrechner-btn.wettrechner-btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    border: none;
}

.wettrechner-container .wettrechner-btn.wettrechner-btn-primary:hover {
    background: linear-gradient(135deg, #5a9de0 0%, #4a90d9 100%);
    color: #fff;
}

.wettrechner-container .wettrechner-btn.wettrechner-btn-secondary {
    color: #666;
    background: #f0f0f0;
    border: none;
}

.wettrechner-container .wettrechner-btn.wettrechner-btn-secondary:hover {
    background: #e5e5e5;
    color: #666;
}

.wettrechner-container .wettrechner-btn {
    flex: 1;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
    border-radius: 10px;
}

/* Theme-Robustheit für die übrigen Button-Typen: Themes setzen auf
   button-Elemente gerne eigene padding-/font-Werte (Live-Theme: 10px 35px,
   16px) und sprengen damit Quick-Stakes, Icon- und Add-Buttons. */
.wettrechner-container .wettrechner-quick-stakes .wettrechner-quick-stake-btn {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    padding: 8px 4px;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
    text-align: center;
    color: #666;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
}

.wettrechner-container .wettrechner-quick-stakes .wettrechner-quick-stake-btn:hover {
    background: #e8f4fc;
    border-color: #4a90d9;
    color: #4a90d9;
}

.wettrechner-container .wettrechner-quick-stakes .wettrechner-quick-stake-btn.active {
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    border-color: #357abd;
    color: #fff;
}

.wettrechner-container .wettrechner-btn-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    background: #fff;
    color: #999;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
}

.wettrechner-container .wettrechner-btn-small {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 8px;
    color: #666;
}

.wettrechner-btn-secondary:hover {
    background: #e5e5e5;
}

/* Result */
.wettrechner-result {
    margin-top: 16px;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.wettrechner-result:empty {
    display: none;
}

.wettrechner-result-text {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.wettrechner-result-profit {
    font-size: 1.4rem;
    font-weight: 700;
}

/* Result States */
.wettrechner-result.gewonnen {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.wettrechner-result.halb-gewonnen {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    color: #856404;
}

.wettrechner-result.zurueck {
    background: linear-gradient(135deg, #e2e3e5 0%, #d6d8db 100%);
    color: #383d41;
}

.wettrechner-result.halb-verloren {
    background: linear-gradient(135deg, #ffe5e5 0%, #ffcccc 100%);
    color: #721c24;
}

.wettrechner-result.verloren {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

/* Error text */
.wettrechner-error-text {
    color: #dc3545;
    font-weight: 500;
}

/* Feldgenaue Fehlermarkierung (Utils.fieldError) */
.wettrechner-container input.wettrechner-input-error,
.wettrechner-container select.wettrechner-input-error {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.wettrechner-error {
    padding: 16px;
    background: #f8d7da;
    border-radius: 8px;
    color: #721c24;
    text-align: center;
}

/* Result Grid for detailed results */
.wettrechner-result-details {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    text-align: left;
}

.wettrechner-result-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.wettrechner-result-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.wettrechner-result-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wettrechner-result-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a2e;
}

.wettrechner-result-value.highlight {
    color: #4a90d9;
}

.wettrechner-result-value.highlight-green {
    color: #28a745;
}

.wettrechner-result-value.highlight-red {
    color: #dc3545;
}

/* Full width result item */
.wettrechner-result-item.full-width {
    grid-column: 1 / -1;
}

/* Selections list for system bets */
.wettrechner-selections-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.wettrechner-selection-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wettrechner-selection-row input {
    flex: 1;
}

.wettrechner-selection-row .wettrechner-selection-name {
    width: 80px;
    flex-shrink: 0;
}

.wettrechner-btn-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    color: #999;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wettrechner-btn-icon:hover {
    border-color: #dc3545;
    color: #dc3545;
    background: #fff5f5;
}

.wettrechner-btn-small {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    font-weight: 500;
    background: #f0f0f0;
    border: 2px dashed #ccc;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wettrechner-btn-small:hover {
    background: #e8f4fc;
    border-color: #4a90d9;
    color: #4a90d9;
}

/* Breakdown table for system bets */
.wettrechner-breakdown {
    margin-top: 12px;
    border-collapse: collapse;
    width: 100%;
    font-size: 0.85rem;
}

.wettrechner-breakdown th,
.wettrechner-breakdown td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.wettrechner-breakdown th {
    background: #f8f9fa;
    font-weight: 600;
    color: #666;
}

.wettrechner-breakdown tr:last-child td {
    border-bottom: none;
}

.wettrechner-breakdown .won {
    color: #28a745;
}

.wettrechner-breakdown .lost {
    color: #dc3545;
}

/* Named System Bet Calculators (Trixie, Patent, Yankee, etc.) */
.wettrechner-named-system .wettrechner-subtitle {
    text-align: center;
    color: #666;
    font-size: 0.85rem;
    margin: -12px 0 16px 0;
}

/* Verwandte-Rechner-Box: Site-Integration UNTERHALB eines Rechners.
   Wird nicht vom Plugin gerendert, sondern als Gutenberg core/details mit
   der Klasse "wettrechner-related" in die Seite gesetzt; das Styling hier
   lässt sie wie die Rechner-Karte aussehen (SEO-lesbar, da natives details). */
details.wettrechner-related {
    max-width: 420px;
    margin: 0 auto 20px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    box-sizing: border-box;
    font-size: 0.9rem;
    color: #444;
}

details.wettrechner-related > summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    color: #1a1a2e;
    padding: 2px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    -webkit-user-select: none;
    user-select: none;
}

details.wettrechner-related > summary::-webkit-details-marker {
    display: none;
}

details.wettrechner-related > summary::before {
    content: '▸';
    color: #4a90d9;
    font-size: 1.1rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

details.wettrechner-related[open] > summary::before {
    transform: rotate(90deg);
}

details.wettrechner-related > summary:hover {
    color: #4a90d9;
}

details.wettrechner-related[open] > summary {
    margin-bottom: 10px;
}

details.wettrechner-related p {
    margin: 0 0 8px;
    font-size: 0.9rem;
    color: #444;
}

details.wettrechner-related ul {
    margin: 0;
    padding-left: 4px;
    list-style: none;
}

/* Eigene Pfeil-Marker; verhindert zugleich Bullet-Leaks von Theme-Regeln
   wie .entry-content ul li::before (höhere Spezifität als deren 0,1,2). */
details.wettrechner-related ul li {
    list-style: none;
    padding-left: 18px;
    position: relative;
    margin: 4px 0;
    font-size: 0.9rem;
    color: #444;
}

details.wettrechner-related ul li::before {
    content: '→';
    position: absolute;
    left: 0;
    top: 0;
    color: #4a90d9;
    font-weight: 600;
}

details.wettrechner-related a {
    color: #4a90d9;
    font-weight: 600;
    text-decoration: none;
}

details.wettrechner-related a:hover {
    text-decoration: underline;
}

/* Veraltetes Ergebnis: nach Eingabeänderung gedimmt + Hinweiszeile */
.wettrechner-result.wettrechner-result-stale {
    opacity: 0.55;
}

.wettrechner-stale-notice {
    margin: 10px 0 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: #b45309;
}

/* Sichtbarer Hinweistext direkt unter einem Eingabefeld */
.wettrechner-field-hint {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: #666;
}

/* Live-Gesamteinsatz-Zeile der Systemwetten-Rechner (Einsatz pro Wette × N) */
.wettrechner-total-stake {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.9rem;
}

.wettrechner-total-stake-label {
    color: #666;
    font-weight: 500;
}

.wettrechner-total-stake-value {
    font-weight: 600;
    color: #1a1a2e;
    white-space: nowrap;
}

.wettrechner-named-system .wettrechner-selection-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wettrechner-named-system .wettrechner-selection-label {
    width: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #666;
    flex-shrink: 0;
}

.wettrechner-named-system .wettrechner-quote-input {
    flex: 1;
    min-width: 0;
}

.wettrechner-named-system .wettrechner-checkbox-label {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.wettrechner-named-system .wettrechner-checkbox-label:hover {
    border-color: #28a745;
}

.wettrechner-named-system .wettrechner-checkbox-label:has(input:checked),
.wettrechner-named-system .wettrechner-checkbox-label.is-checked {
    border-color: #28a745;
    background: #d4edda;
}

.wettrechner-named-system .wettrechner-won-checkbox {
    width: 0;
    height: 0;
    opacity: 0;
    position: absolute;
}

.wettrechner-named-system .wettrechner-checkbox-text {
    font-size: 0.85rem;
    color: #888;
    white-space: nowrap;
    transition: color 0.2s ease;
}

.wettrechner-named-system .wettrechner-checkbox-label:has(input:checked) .wettrechner-checkbox-text,
.wettrechner-named-system .wettrechner-checkbox-label.is-checked .wettrechner-checkbox-text {
    color: #28a745;
}

/* systemwetten: sichtbarer Checked-Zustand auch dann, wenn ein Optimierer
   die native Checkbox-Darstellung des Themes verändert. */
.wettrechner-systemwetten .wettrechner-checkbox-label.is-checked .wettrechner-checkbox-text {
    color: #28a745;
    font-weight: 600;
}

/* Subtitle for other calculators */
.wettrechner-subtitle {
    text-align: center;
    color: #666;
    font-size: 0.85rem;
    margin: -12px 0 16px 0;
}

/* Quick-stake buttons */
.wettrechner-quick-stakes {
    /* Eine Reihe gleich breiter Presets, egal wie viele — kein Umbruch,
       bei dem «100 CHF» wie ein Aktions-Button in voller Breite wirkt. */
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 6px;
    margin-top: 8px;
}

.wettrechner-quick-stake-btn {
    min-width: 0;
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.wettrechner-quick-stake-btn:hover {
    background: #e8f4fc;
    border-color: #4a90d9;
    color: #4a90d9;
}

.wettrechner-quick-stake-btn:active {
    transform: scale(0.95);
}

.wettrechner-quick-stake-btn.active {
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    border-color: #357abd;
    color: #fff;
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.3);
}

/* Auto-save indicator */
.wettrechner-autosave-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #999;
    margin-top: 8px;
}

.wettrechner-autosave-indicator::before {
    content: '✓';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 10px;
    background: #d4edda;
    color: #28a745;
    border-radius: 50%;
}

/* Keyboard hint */
.wettrechner-keyboard-hint {
    display: none;
    font-size: 0.7rem;
    color: #999;
    text-align: center;
    margin-top: 12px;
}

@media (min-width: 768px) {
    .wettrechner-keyboard-hint {
        display: block;
    }
}

.wettrechner-keyboard-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    font-family: inherit;
    font-size: 0.7rem;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 1px 0 #ccc;
}

/* Responsive */
@media (max-width: 480px) {
    .wettrechner-container {
        margin: 10px;
        padding: 16px;
        max-width: none;
    }

    /* Verwandte-Rechner-Box spiegelt die Rechner-Karte auch mobil:
       gleiche Aussenabstaende und gleiches horizontales Padding wie
       .wettrechner-container, sonst steht die Box breiter/versetzt da. */
    details.wettrechner-related {
        margin: 0 10px 20px;
        padding: 12px 16px;
        max-width: none;
    }

    .wettrechner-container .wettrechner-quick-stakes .wettrechner-quick-stake-btn {
        padding: 8px 2px;
        font-size: 0.75rem;
    }

    .wettrechner-title {
        font-size: 1.3rem;
    }

    .wettrechner-buttons {
        flex-direction: column;
    }

    .wettrechner-tooltip-icon::after {
        max-width: 200px;
        left: auto;
        right: -10px;
        transform: none;
    }

    .wettrechner-tooltip-icon::before {
        left: auto;
        right: 5px;
        transform: none;
    }
}
