/* ═══ KW PWA — Watchlist, Alerts, Install Banner ═══ */

/* ── Star & Bell buttons ── */
.kw-star-btn, .kw-bell-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 6px 8px;
    opacity: 0.4;
    transition: opacity 0.2s, transform 0.15s;
    line-height: 1;
    -webkit-tap-highlight-color: rgba(0,182,154,0.3);
    touch-action: manipulation;
    user-select: none;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.kw-star-btn:hover, .kw-bell-btn:hover { opacity: 1; transform: scale(1.2); }
.kw-star-btn:active, .kw-bell-btn:active { opacity: 1; transform: scale(0.95); }
.kw-star-btn--active { opacity: 1; color: #f1c40f; }
.kw-star-btn { font-size: 1.2rem; }
.kw-bell-btn { font-size: 1rem; }

/* ── Hide empty sections (no CLS — elements exist but are invisible when empty) ── */
.kw-watchlist:not(:has(.kw-watchlist-card)) { margin: 0 !important; padding: 0 !important; border: 0 !important; overflow: hidden; max-height: 0; }
.kw-my-alerts:not(:has(.kw-my-alerts__item)) { margin: 0 !important; padding: 0 !important; border: 0 !important; overflow: hidden; max-height: 0; }
.kw-watchlist {
    background: rgba(0,182,154,0.08);
    border: 1px solid rgba(0,182,154,0.2);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}
.kw-watchlist__header h2 {
    font-size: 0.95rem;
    color: #00b69a;
    margin: 0 0 12px;
}
.kw-watchlist__grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 8px !important;
}
@media (max-width: 1100px) { .kw-watchlist__grid { grid-template-columns: repeat(3, 1fr) !important; } }
@media (max-width: 820px) { .kw-watchlist__grid { grid-template-columns: repeat(2, 1fr) !important; } }
@media (max-width: 560px) { .kw-watchlist__grid { grid-template-columns: 1fr !important; } }

.kw-watchlist-card {
    background: rgba(28,59,88,0.6) !important;
    border: 1px solid rgba(0,182,154,0.3) !important;
}

/* ── Search input ── */
.kw-search-wrap {
    margin: 12px 0 16px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
}
.kw-search-clear {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
    line-height: 1;
}
.kw-search-clear:hover {
    background: #c0392b;
    transform: translateY(-50%) scale(1.1);
}
.kw-search-inner {
    position: relative;
    width: 300px;
    flex-shrink: 1;
    min-width: 0;
}
.kw-search-input {
    width: 100%;
    padding: 12px 18px 12px 40px;
    background: rgba(28,59,88,0.6);
    border: 1px solid rgba(0,182,154,0.2);
    border-radius: 10px;
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23647c8c' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 14px center;
}
.kw-search-input:focus {
    border-color: #00b69a;
    box-shadow: 0 0 0 2px rgba(0,182,154,0.15);
}
.kw-search-input::placeholder {
    color: #647c8c;
}

@media (max-width: 820px) {
    .kw-search-wrap {
        margin: 8px 0 12px;
        flex-wrap: wrap;
    }
    .kw-search-inner {
        width: 100% !important;
        flex-shrink: 1 !important;
    }
    .kw-search-input {
        width: 100% !important;
        padding: 14px 44px 14px 42px;
        font-size: 1rem;
        border-radius: 12px;
    }
    .kw-search-wrap .kw-toggles {
        order: -1;
        width: 100%;
        justify-content: flex-end;
        margin-bottom: 4px;
    }
}

/* ── No results message ── */
.kw-no-results {
    text-align: center;
    padding: 20px;
    color: #e67e22;
    font-size: 0.9rem;
    font-weight: 500;
    background: rgba(230,126,34,0.08);
    border: 1px dashed rgba(230,126,34,0.3);
    border-radius: 8px;
    margin-top: 8px;
}

/* ── Current rate in modal ── */
.kw-modal__current {
    background: rgba(0,182,154,0.1);
    border: 1px solid rgba(0,182,154,0.3);
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    color: #b5c2cd;
}
.kw-modal__current strong {
    color: #00b69a;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
}

/* ── My Alerts list ── */
.kw-my-alerts {
    background: rgba(231,76,60,0.06);
    border: 1px solid rgba(231,76,60,0.2);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
}
.kw-my-alerts__header h2 {
    font-size: 0.9rem;
    color: #e67e22;
    margin: 0 0 10px;
}
.kw-my-alerts__list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.kw-my-alerts__item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(28,59,88,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.8rem;
    transition: opacity 0.2s;
}
.kw-my-alerts__pair {
    color: #fff;
    font-weight: 700;
}
body.kw-light .kw-my-alerts__pair {
    color: #0d1b2a;
}
.kw-my-alerts__dir {
    color: #b5c2cd;
}
body.kw-light .kw-my-alerts__dir {
    color: #3a4a5c;
}
.kw-my-alerts__del {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}
.kw-my-alerts__del:hover {
    opacity: 1;
}

/* ── Alert Modal (light theme) ── */
body.kw-light .kw-modal { background: #ffffff; border-color: #dce2e8; }
body.kw-light .kw-modal__header { border-bottom-color: #eee; }
body.kw-light .kw-modal__header h3 { color: #1a2332; }
body.kw-light .kw-modal__close { color: #aaa; }
body.kw-light .kw-modal__close:hover { color: #333; }
body.kw-light .kw-modal__body { color: #3a4a5c; }
body.kw-light .kw-modal__input { background: #f4f6f9; border-color: #cdd5de; color: #1a2332; }
body.kw-light .kw-modal__input:focus { border-color: #00b69a; }
body.kw-light .kw-modal__current { background: rgba(0,182,154,0.06); border-color: rgba(0,182,154,0.2); color: #3a4a5c; }
body.kw-light .kw-modal__option label { color: #3a4a5c; }

/* ── Help panel (light theme) ── */
body.kw-light .kw-help-panel { background: #ffffff; border-color: #dce2e8; }
body.kw-light .kw-help-panel h3 { color: #00916b; }
body.kw-light .kw-help-step strong { color: #1a2332; }
body.kw-light .kw-help-step p { color: #3a4a5c; }
body.kw-light .kw-help-step { border-bottom-color: #eee; }

/* ── Toast (light theme) ── */
body.kw-light .kw-toast { background: #00916b; }

/* ── Alert Modal ── */
.kw-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.kw-modal {
    background: #1c3b58;
    border: 1px solid rgba(0,182,154,0.3);
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    color: #b5c2cd;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.kw-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.kw-modal__header h3 {
    font-size: 1rem;
    color: #fff;
    margin: 0;
}
.kw-modal__close {
    background: none;
    border: none;
    color: #647c8c;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
}
.kw-modal__close:hover { color: #fff; }
.kw-modal__body { padding: 20px; }
.kw-modal__option {
    margin-bottom: 14px;
}
.kw-modal__option label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}
.kw-modal__option input[type="radio"] {
    accent-color: #00b69a;
    width: 16px;
    height: 16px;
}
.kw-modal__input {
    width: 100%;
    margin-top: 8px;
    padding: 10px 14px;
    background: #152d45;
    border: 1px solid rgba(0,182,154,0.3);
    border-radius: 6px;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
}
.kw-modal__input:focus {
    outline: none;
    border-color: #00b69a;
}
.kw-modal__btn {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    background: #00b69a;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.kw-modal__btn:hover { background: #00a08a; }
.kw-modal__btn:disabled { background: #647c8c; cursor: wait; }

/* ── Install Banner (mobile only) ── */
.kw-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99998;
    background: linear-gradient(135deg, #152d45, #1c3b58);
    border-top: 2px solid #00b69a;
    padding: 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.kw-install-banner__content {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.kw-install-banner__text {
    flex: 1;
    min-width: 200px;
}
.kw-install-banner__text strong {
    display: block;
    color: #fff;
    font-size: 0.95rem;
    margin-bottom: 4px;
}
.kw-install-banner__text span {
    font-size: 0.78rem;
    color: #b5c2cd;
    line-height: 1.4;
}
.kw-install-banner__ios {
    font-size: 0.8rem;
    color: #b5c2cd;
    padding: 8px 12px;
    background: rgba(0,182,154,0.1);
    border-radius: 6px;
}
.kw-install-banner__btn {
    padding: 10px 24px;
    background: #00b69a;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}
.kw-install-banner__btn:hover { background: #00a08a; }
.kw-install-banner__close {
    position: absolute;
    top: 8px;
    right: 12px;
    background: none;
    border: none;
    color: #647c8c;
    font-size: 1.2rem;
    cursor: pointer;
}

/* ── Toast ── */
.kw-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #00b69a;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    z-index: 99999;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: 0 4px 20px rgba(0,182,154,0.3);
}
.kw-toast--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Floating Help Tab + Panel ── */
.kw-help-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: #00b69a;
    color: #fff;
    padding: 14px 8px;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    z-index: 9990;
    writing-mode: vertical-rl;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    box-shadow: -2px 0 12px rgba(0,0,0,0.3);
    transition: right 0.3s, opacity 0.3s;
    -webkit-tap-highlight-color: rgba(0,182,154,0.3);
    touch-action: manipulation;
    user-select: none;
}
.kw-help-tab span {
    display: block;
    transform: rotate(180deg);
}
.kw-help-tab:hover {
    box-shadow: -4px 0 16px rgba(0,182,154,0.4);
}
.kw-help-tab--hidden {
    right: -60px;
    opacity: 0;
    pointer-events: none;
}

.kw-help-panel {
    position: fixed;
    right: -340px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: 80vh;
    overflow-y: auto;
    background: #1c3b58;
    border: 1px solid rgba(0,182,154,0.3);
    border-right: none;
    border-radius: 12px 0 0 12px;
    padding: 20px;
    z-index: 9991;
    box-shadow: -4px 0 30px rgba(0,0,0,0.5);
    transition: right 0.35s ease;
}
.kw-help-panel--open {
    right: 0;
}
.kw-help-panel__close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: #647c8c;
    font-size: 1.3rem;
    cursor: pointer;
}
.kw-help-panel__close:hover { color: #fff; }

.kw-help-panel h3 {
    color: #00b69a;
    font-size: 1rem;
    margin: 0 0 16px;
}

.kw-help-step {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.kw-help-step:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.kw-help-step strong {
    display: block;
    color: #fff;
    font-size: 0.85rem;
    margin-bottom: 4px;
}
.kw-help-step p {
    color: #b5c2cd;
    font-size: 0.78rem;
    line-height: 1.5;
    margin: 0;
}

@media (max-width: 768px) {
    .kw-help-tab {
        position: fixed;
        top: auto;
        top: 50%;
        right: 0;
        left: auto;
        transform: translateY(-50%);
        writing-mode: horizontal-tb;
        transform: none;
        border-radius: 24px;
        padding: 10px 18px;
        font-size: 0.8rem;
        box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    }
    .kw-help-tab span {
        transform: none;
    }
    .kw-help-tab--hidden {
        right: -200px;
        opacity: 0;
        transform: translateY(-50%);
    }
    .kw-help-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        max-height: 75vh;
        transform: translateY(100%);
        border-radius: 16px 16px 0 0;
        border: none;
        border-top: 2px solid #00b69a;
    }
    .kw-help-panel--open {
        right: 0;
        transform: translateY(0);
    }
}

/* ── Hide install banner on desktop ── */
@media (min-width: 769px) {
    .kw-install-banner { display: none !important; }
}
