/* Modal, watchlist-remove, and help-system styles.
   Extracted verbatim from templates/index.html inline <style> (was lines 980-1210).
   Must be linked AFTER styles.css — styles.css also defines .modal-overlay /
   .modal-content (lines ~1010-1182) and these rules win by source order. */

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(31, 41, 55, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}
.modal-overlay.hidden {
    display: none !important;
}
.modal-content {
    background: white;
    padding: 1.5rem;
    border-radius: var(--r-sm);
    width: 90%;
    max-width: 600px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.modal-content h2 {
    margin-right: 2rem;
}
.modal-content h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #4b5563;
}
.modal-ticker-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: var(--r-xs);
    max-height: 150px;
    overflow-y: auto;
}
.modal-ticker-list span {
    background: var(--status-gain-bg);
    color: var(--status-gain-text);
    padding: 0.25rem 0.75rem;
    border-radius: var(--r-full);
    font-size: 0.875rem;
    font-weight: 500;
}
.modal-ticker-list .ticker-invalid {
    background: var(--status-loss-bg);
    color: var(--status-loss-text);
    text-decoration: line-through;
}
.modal-ticker-list .ticker-duplicate {
    background: var(--status-warn-bg);
    color: var(--status-warn);
}
.modal-content h3.text-orange { color: #c2410c; }
.modal-content h3.text-red { color: #dc2626; }

/* New style for the remove button on watchlist cards */
.btn-watchlist-remove {
    background: transparent;
    border: none;
    color: #9ca3af; /* Light gray */
    font-size: 1.25rem;
    font-weight: bold;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    line-height: 1;
    border-radius: var(--r-xs);
    transition: background-color 0.2s ease, color 0.2s ease;
}
.btn-watchlist-remove:hover {
    background-color: #fee2e2; /* light red */
    color: #b91c1c; /* dark red */
}

/* Shake animation for watchlist remove button */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.btn-watchlist-remove.confirm-delete {
    animation: shake 0.5s ease-in-out;
    color: #dc2626 !important; /* bright red */
    background-color: #fee2e2 !important;
    font-weight: bolder;
}

/* Help System Styles */
/* Lives inline inside the masthead h1 (subtitles retired 2026-08-17):
   a naked "?" glyph off the title baseline — no ring, no fill. */
.help-button {
    background: none;
    border: none;
    padding: 0 2px;
    margin-left: 10px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-4);
    cursor: pointer;
    vertical-align: 6px;
    transition: color 0.2s;
}

.help-button:hover {
    color: var(--accent, #764ba2);
}

.help-button:focus-visible {
    outline: 2px solid var(--accent, #764ba2);
    outline-offset: 2px;
    border-radius: 2px;
}

.help-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transition: right 0.3s ease-in-out;
    z-index: 3000;
    display: flex;
    flex-direction: column;
}

.help-panel.open {
    right: 0;
}

.help-panel-header {
    background: var(--accent, #764ba2);
    color: var(--text-on-accent, white);
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.help-panel-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.help-panel-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-xs);
    transition: background 0.2s;
}

.help-panel-close:hover {
    background: rgba(255,255,255,0.2);
}

.help-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.help-section {
    margin-bottom: 2rem;
}

.help-section h3 {
    color: var(--accent-text, #764ba2);
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.help-steps {
    margin: 0;
    padding-left: 1.5rem;
    color: #374151;
}

.help-steps li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.help-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 2999;
    transition: opacity 0.3s;
}

.help-backdrop.hidden {
    display: none;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .help-panel {
        width: 100%;
        right: -100%;
    }

    .help-button {
        font-size: 15px;
    }
}

/* ============================================================
   Theme picker (owned by static/js/themes.js) — anchored popover
   with a grid of theme preview cards. Each card carries its own
   data-theme attribute so themes.css scopes that theme's --blob-*
   variables to the card; the preview gradient is pure CSS.
   ============================================================ */

.theme-picker-container {
    position: relative;
}

.theme-picker-popover {
    position: absolute;
    top: calc(100% + 8px);
    /* Anchored in the top-right utility satellite — open leftward so the
       panel can never overflow the viewport edge */
    right: 0;
    left: auto;
    width: 300px;
    background: var(--surface-1, white);
    border: 1px solid var(--stroke-1);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-3);
    padding: var(--sp-4);
    z-index: var(--z-popover);
}

.theme-picker-heading {
    font-weight: 600;
    color: var(--text-1);
    margin-bottom: var(--sp-3);
}

.theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-2);
}

.theme-card {
    position: relative;
    height: 72px;
    border: 1px solid var(--stroke-1);
    border-radius: var(--r-md);
    cursor: pointer;
    overflow: hidden;
    padding: 0;
    /* Miniature ambient-field preview from the card's own data-theme scope */
    background:
        radial-gradient(90% 90% at 15% 20%, color-mix(in srgb, var(--blob-1) 70%, transparent), transparent 70%),
        radial-gradient(90% 90% at 85% 25%, color-mix(in srgb, var(--blob-2) 65%, transparent), transparent 70%),
        radial-gradient(90% 90% at 50% 100%, color-mix(in srgb, var(--blob-3) 60%, transparent), transparent 70%),
        #F6F7FB;
    transition: border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.theme-card:hover {
    transform: translateY(-1px);
    border-color: var(--stroke-2);
}

.theme-card.selected {
    border: 2px solid var(--accent);
}

.theme-card-name {
    position: absolute;
    left: 8px;
    bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #171A2B;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

/* ============================================================
   Toast notifications (owned by static/js/notifications.js).
   Migrated from JS cssText + injected <style id="toast-animations">.
   ============================================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    /* Pre-redesign stacking: above modals (2000-3000) and legacy 9999s.
       Migrates to var(--z-toast) when the full z-ladder lands (PR8). */
    z-index: 10000;
    pointer-events: none;
}

@keyframes toast-slide-in {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-fade-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.3); }
}

@keyframes badge-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes badge-flash {
    0%, 100% { background-color: var(--badge-color); }
    50% { background-color: var(--primary-accent); }
}

/* Type modifiers set the palette; base rules consume it */
.toast--success {
    --toast-color: var(--status-gain);
    --toast-bg: var(--status-gain-bg);
    --toast-border: var(--status-gain-border);
}

.toast--error {
    --toast-color: var(--status-loss);
    --toast-bg: var(--status-loss-bg);
    --toast-border: var(--status-loss-border);
}

.toast--info {
    --toast-color: var(--status-info);
    --toast-bg: var(--status-info-bg);
    --toast-border: var(--status-info-border);
}

.toast--warning {
    --toast-color: var(--status-warn);
    --toast-bg: var(--status-warn-bg);
    --toast-border: var(--status-warn-border);
}

.toast-element {
    display: flex;
    align-items: center;
    min-width: 300px;
    max-width: 500px;
    padding: 16px;
    background: var(--toast-bg);
    border: 2px solid var(--toast-border);
    border-radius: var(--r-sm);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    pointer-events: auto;
    margin-bottom: 10px;
    animation: toast-slide-in 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast-element.removing {
    animation: toast-fade-out 0.3s ease-out forwards;
}

.toast-icon {
    color: var(--toast-color);
    font-weight: bold;
    font-size: 18px;
    margin-right: 10px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    color: var(--text-2);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.toast-close {
    color: var(--toast-color);
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
    opacity: 0.6;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    opacity: 1;
}
