/* ==========================================
   BACK-BACK RECHNER – Styles
   NinjaBet Suite Design System
   ========================================== */

:root {
    --color-bg:             #f5f5f7;
    --color-surface:        #ffffff;
    --color-text:           #1d1d1f;
    --color-text-secondary: #86868b;
    --color-border:         #d2d2d7;
    --color-accent:         #007AFF;
    --color-success:        #34C759;
    --color-danger:         #FF3B30;
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.10);
    --radius-sm:  8px;
    --radius-md:  12px;
    --radius-lg:  16px;
}

[data-theme="dark"] {
    --color-bg:             #000000;
    --color-surface:        #1c1c1e;
    --color-text:           #f5f5f7;
    --color-text-secondary: #98989d;
    --color-border:         #38383a;
    --shadow-sm:  0 1px 3px rgba(0,0,0,0.30);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.40);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    min-height: 100vh;
}

.app-container {
    max-width: 700px;
    margin: 0 auto;
    padding: 20px;
}

/* ── Header ─────────────────────────────────────────────────────────────── */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}

.back-link {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
}
.back-link:hover { opacity: 0.8; }

.brand-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Workspace Button */
.workspace-btn {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--color-accent);
    background: transparent;
    color: var(--color-accent);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
}
.workspace-btn:hover {
    background: var(--color-accent);
    color: white;
}

/* Info Button */
.info-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1.5px solid var(--color-accent);
    background: transparent;
    color: var(--color-accent);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.info-btn:hover {
    background: var(--color-accent);
    color: white;
}

/* Theme Toggle */
.theme-toggle-wrapper {
    width: 50px;
    height: 28px;
    background: var(--color-border);
    border-radius: 14px;
    cursor: pointer;
    position: relative;
    transition: background 0.3s;
    flex-shrink: 0;
}
[data-theme="dark"] .theme-toggle-wrapper { background: var(--color-accent); }

.theme-toggle-knob {
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .theme-toggle-knob { transform: translateX(22px); }

/* ── Panels ──────────────────────────────────────────────────────────────── */

.panel {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.panel-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

/* ── Notiz ───────────────────────────────────────────────────────────────── */

.user-note {
    width: 100%;
    height: 34px;
    resize: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
    padding: 6px 8px;
    outline: none;
    transition: border-color 0.2s;
    overflow: hidden;
}
.user-note:focus { border-color: var(--color-accent); }
.user-note::placeholder { color: var(--color-text-secondary); opacity: 0.6; font-weight: 400; }

/* ── Mode Selector ───────────────────────────────────────────────────────── */

.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.mode-option { cursor: pointer; }
.mode-option input[type="radio"] { display: none; }

.mode-label {
    display: block;
    padding: 3px 2px;
    text-align: center;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 9px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg);
    transition: all 0.2s;
    cursor: pointer;
    user-select: none;
}

.mode-option input[type="radio"]:checked + .mode-label {
    background: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
    font-weight: 600;
}

.mode-label:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}
.mode-option input[type="radio"]:checked + .mode-label:hover {
    color: white;
}

/* ── Input Fields ────────────────────────────────────────────────────────── */

.input-group {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
}

.input-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
}

.input-field-wrap {
    position: relative;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg);
    transition: border-color 0.2s;
    width: 180px;
    flex-shrink: 0;
}
.input-field-wrap:focus-within {
    border-color: var(--color-accent);
}

.input-prefix,
.input-suffix {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-secondary);
    pointer-events: none;
    user-select: none;
}
.input-prefix { left: 10px; }
.input-suffix { right: 10px; }

.form-input-clean {
    width: 100%;
    padding: 11px 26px;
    border: none;
    font-size: 18px;
    font-weight: 600;
    background: transparent;
    color: var(--color-text);
    text-align: center;
    outline: none;
    font-family: inherit;
}

.field-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 18px 0 14px;
    color: var(--color-text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.field-divider::before,
.field-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

/* ── Result Bar ──────────────────────────────────────────────────────────── */

.result-bar {
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: var(--shadow-md);
}

.result-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: white;
    flex-wrap: wrap;
}

.result-bar-back    { background: #007AFF; }
.result-bar-lay     { background: #E53935; }
.result-bar-haftung {
    background: rgba(0,0,0,0.45);
    padding: 7px 20px !important;
}
.result-bar-haftung .result-bar-label { font-size: 10px; }
.result-bar-haftung .result-bar-stake { font-size: 14px; }

.result-bar-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.6px;
    white-space: nowrap;
    min-width: 110px;
}

.result-bar-stake {
    font-size: 18px;
    font-weight: 800;
    background: rgba(255,255,255,0.22);
    padding: 3px 12px;
    border-radius: 8px;
    white-space: nowrap;
}

.result-bar-text {
    font-size: 10px;
    opacity: 0.8;
    white-space: nowrap;
}

.result-bar-odds {
    font-size: 14px;
    font-weight: 700;
    background: rgba(255,255,255,0.22);
    padding: 3px 10px;
    border-radius: 8px;
    white-space: nowrap;
}

.copy-icon-btn {
    background: rgba(255,255,255,0.22);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.copy-icon-btn:hover { background: rgba(255,255,255,0.38); }

/* ── PT Button ───────────────────────────────────────────────────────────── */

.pt-add-btn {
    display: block;
    width: calc(100% - 32px);
    margin: 0 16px 16px;
    padding: 13px 20px;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, background 0.3s;
    letter-spacing: 0.3px;
}
.pt-add-btn:hover { opacity: 0.85; }
.pt-add-btn.added { background: var(--color-success); }

/* ── Profit Display ──────────────────────────────────────────────────────── */

.profit-display-panel {
    text-align: center;
    padding: 28px 20px;
}

.profit-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.profit-amount {
    font-size: 44px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 10px;
    color: var(--color-text);
}
.profit-amount.positive { color: var(--color-success); }
.profit-amount.negative { color: var(--color-danger); }

.profit-sublabel {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.rating-text {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.badge-back { background: #007AFF; }
.badge-lay  { background: #E53935; }

/* ── Payout Table ────────────────────────────────────────────────────────── */

.payout-table {
    width: 100%;
    border-collapse: collapse;
}

.payout-table th {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-secondary);
    text-align: right;
    padding: 6px 10px 10px;
    border-bottom: 1px solid var(--color-border);
}
.payout-table th:first-child { text-align: left; }

.payout-table td {
    padding: 12px 10px;
    vertical-align: middle;
}
.payout-table tr + tr td { border-top: 1px solid var(--color-border); }

.outcome-badge {
    display: inline-block;
    background: var(--color-accent);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 5px;
    white-space: nowrap;
    letter-spacing: 0.3px;
}

.payout-val {
    text-align: right;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text-secondary);
}
.payout-val.positive { color: var(--color-success); }
.payout-val.negative { color: var(--color-danger); }

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

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.active { display: flex; }

.modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    max-width: 480px;
    width: 100%;
    box-shadow: var(--shadow-md);
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 0;
    margin-bottom: 16px;
}
.modal-header h2 {
    font-size: 17px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-bg);
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.modal-close:hover {
    background: var(--color-danger);
    color: white;
}

.modal-body {
    padding: 0 20px 24px;
}
.modal-body p {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.65;
    margin-bottom: 12px;
}
.modal-body p:last-child { margin-bottom: 0; }
.modal-body strong { color: var(--color-text); }
.modal-body em { font-style: italic; }

/* ── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 480px) {
    .app-container { padding: 12px; }

    .mode-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    .mode-label { font-size: 12px; padding: 9px 4px; }

    .input-group {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .input-field-wrap { width: 100%; }

    .result-bar-label { min-width: 90px; font-size: 9px; }
    .result-bar-stake { font-size: 16px; }

    .profit-amount { font-size: 36px; }

    .payout-table th,
    .payout-table td { padding: 8px 6px; }
    .outcome-badge { font-size: 9px; padding: 3px 6px; }
    .payout-val { font-size: 13px; }
}
