/* Buttons & Inputs */
.btn {
    border: none;
    cursor: pointer;
    padding: 16px 28px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition:
        transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        box-shadow 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        background-color 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        color 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
        border-color 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-size: 15px;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

.btn:active {
    transform: scale(0.97);
}

.btn.primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow:
        0 4px 15px rgba(139, 92, 246, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

[data-theme='light'] .btn.primary {
    box-shadow:
        0 4px 15px rgba(99, 102, 241, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn.primary:hover {
    box-shadow:
        0 10px 30px rgba(139, 92, 246, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-3px) scale(1.02);
    filter: brightness(1.15);
}

[data-theme='light'] .btn.primary:hover {
    box-shadow:
        0 10px 30px rgba(99, 102, 241, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn.primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: skewX(-25deg);
    z-index: -1;
    transition: none;
}

.btn.primary:hover::after {
    animation: shine 1.2s ease-out infinite;
}

@keyframes shine {
    0% {
        left: -100%;
    }

    100% {
        left: 200%;
    }
}

.btn.ghost {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn.ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
    border-color: var(--text-dim);
    transform: translateY(-1px) scale(1.02);
}

[data-theme='light'] .btn.ghost {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--border);
    color: var(--text-muted);
}

[data-theme='light'] .btn.ghost:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--primary);
    border-color: var(--primary);
}

.btn.text-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    padding: 8px 16px;
    font-size: 13px;
}

.btn.text-danger:hover {
    background: rgba(239, 68, 68, 0.2);
}

.btn.full-width {
    width: 100%;
    margin-top: 24px;
}

.btn.sm {
    padding: 10px 18px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn.lg {
    padding: 20px 40px;
    font-size: 17px;
    min-width: 240px;
}

.icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    background: var(--bg-suface-light);
    color: var(--primary);
    border-color: var(--border);
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--primary-glow);
}

[data-theme='light'] .icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

/* Inputs */
input[type='number'],
input[type='text'],
select {
    width: 100%;
    padding: 16px 18px;
    background: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    outline: none;
    font-family: inherit;
    font-size: 15px;
    transition:
        border-color 0.25s ease,
        box-shadow 0.25s ease,
        background-color 0.25s ease;
}

[data-theme='light'] input,
[data-theme='light'] select {
    background: #ffffff !important;
    border-color: #e2e8f0;
    color: #1e293b;
}

input:focus,
select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
    background: var(--bg-suface-light);
}

[data-theme='light'] input:focus,
[data-theme='light'] select:focus {
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* --- Form Elements & Grids --- */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.advanced-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.strategy-advanced-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.strategy-advanced-grid.compact {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.range-inputs {
    display: flex;
    gap: 8px;
    align-items: center;
}

.toggles {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 20px 0;
}

.action-area {
    margin-top: 32px;
}

.text-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    transition:
        color 0.2s ease,
        opacity 0.2s ease;
}

.text-btn:hover {
    text-decoration: underline;
    opacity: 0.8;
}

.strategy-panel {
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
}

[data-theme='light'] .strategy-panel {
    background: rgba(0, 0, 0, 0.02);
}

.preset-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
}

.preset-select {
    min-width: 0;
}

.preset-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Checkboxes */
.check-box {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-main);
    user-select: none;
}

.check-box input {
    display: none;
}

.check-box .checkmark {
    width: 20px;
    height: 20px;
    min-width: 20px;
    border-radius: 6px;
    border: 2px solid var(--border);
    background: var(--bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        border-color 0.2s ease,
        background-color 0.2s ease,
        box-shadow 0.2s ease;
}

.check-box:hover .checkmark {
    border-color: var(--primary-glow);
}

.check-box input:checked + .checkmark {
    background: var(--primary);
    border-color: var(--primary);
}

.check-box input:checked + .checkmark::after {
    content: '✓';
    color: white;
    font-size: 14px;
    font-weight: bold;
}

/* Results section & rows */
.result-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    padding: 16px 20px;
    border-radius: var(--radius-md);
    transition:
        transform 0.2s,
        box-shadow 0.2s;
}

[data-theme='light'] .result-item {
    background: #f8fafc;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--border-light);
}

.result-actions {
    display: flex;
    gap: 8px;
}

.row-center {
    display: flex;
    align-items: center;
}

.button-group {
    display: flex;
    gap: 12px;
}

/* Balls - 3D Premium Look */
.ball-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.ball-container.center {
    justify-content: center;
    padding: 24px 0;
}

.ball {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    font-family: 'Outfit', sans-serif;
    font-size: 18px;
    position: relative;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    box-shadow:
        inset 0 4px 6px rgba(255, 255, 255, 0.4),
        inset 0 -4px 6px rgba(0, 0, 0, 0.2),
        0 6px 12px rgba(0, 0, 0, 0.2);
    background: #334155;
    /* Default */
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ball::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 10px;
    width: 14px;
    height: 8px;
    border-radius: 50%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), transparent);
    transform: rotate(-30deg);
    opacity: 0.7;
}

.ball.sm {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

.ball.yellow {
    background: radial-gradient(circle at 40% 30%, #fcd34d, #d97706);
    border-color: #fbbf24;
}

.ball.blue {
    background: radial-gradient(circle at 40% 30%, #60a5fa, #2563eb);
    border-color: #3b82f6;
}

.ball.red {
    background: radial-gradient(circle at 40% 30%, #f87171, #dc2626);
    border-color: #ef4444;
}

.ball.gray {
    background: radial-gradient(circle at 40% 30%, #94a3b8, #475569);
    border-color: #64748b;
}

.ball.green {
    background: radial-gradient(circle at 40% 30%, #34d399, #059669);
    border-color: #10b981;
}

/* Switch & Checkbox */
.switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 30px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bg-deep);
    border: 1px solid var(--border);
    border-radius: 30px;
    transition:
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.slider:before {
    position: absolute;
    content: '';
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 3px;
    background-color: var(--text-muted);
    border-radius: 50%;
    transition:
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* --- PWA Update Toast --- */
.update-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--primary);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 90vw;
}

[data-theme='light'] .update-toast {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--primary);
    box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.15);
    color: var(--text-main);
}

.update-toast span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-main);
}

.update-toast button {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        background-color 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}

.update-toast #reloadBtn {
    background: var(--primary);
    color: white;
    border: none;
}

.update-toast #reloadBtn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.update-toast #dismissBtn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.update-toast #dismissBtn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

[data-theme='light'] .update-toast #dismissBtn:hover {
    background: rgba(0, 0, 0, 0.05);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

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

@media (max-width: 768px) {
    .update-toast {
        bottom: 90px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: auto;
        min-width: 300px;
        justify-content: space-between;
    }

    @keyframes slideUp {
        from {
            opacity: 0;
            transform: translate(-50%, 20px) scale(0.95);
        }

        to {
            opacity: 1;
            transform: translate(-50%, 0) scale(1);
        }
    }
}

input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}

input:checked + .slider:before {
    transform: translateX(22px);
    background-color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Stepper */
.stepper {
    display: flex;
    align-items: center;
    background: var(--bg-deep);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    padding: 4px;
    gap: 4px;
    transition: border-color 0.2s;
}

.stepper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.step-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    fill: currentColor;
    padding: 8px 12px;
    font-size: 16px;
    cursor: pointer;
    border-radius: 6px;
    transition:
        transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
        border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-btn:hover {
    background: var(--bg-suface-light);
    color: var(--primary);
    border-color: var(--primary-glow);
    transform: translateY(-1px);
}

.step-btn:active {
    transform: scale(0.95);
}

.stepper input {
    width: 50px;
    text-align: center;
    border: none !important;
    background: transparent !important;
    padding: 0;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-main);
    box-shadow: none !important;
}
