/* Per-symbol alert control and settings popover. */
.sheet-symbol-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 10px;
}

.sheet-market-meta { justify-self: start; max-width: 100%; }
.sheet-price-summary { justify-self: end; }

.sheet-symbol-alert-control {
    align-self: center;
    justify-self: center;
}

.sheet-symbol-alert-trigger {
    min-width: 72px;
    padding: 0;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-secondary);
    background: transparent;
    border: 0;
    font-family: var(--font-ui);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sheet-symbol-alert-icon {
    position: relative;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.72);
    transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.sheet-symbol-alert-trigger:hover .sheet-symbol-alert-icon,
.sheet-symbol-alert-trigger:focus-visible .sheet-symbol-alert-icon {
    color: var(--text-primary);
    border-color: rgba(99, 102, 241, 0.6);
}

.sheet-symbol-alert-trigger:focus-visible { outline: none; }

.sheet-symbol-alert-trigger.has-alerts { color: #d1fae5; }
.sheet-symbol-alert-trigger.has-alerts .sheet-symbol-alert-icon {
    color: #34d399;
    border-color: rgba(52, 211, 153, 0.5);
    background: rgba(6, 78, 59, 0.35);
}

.sheet-symbol-alert-trigger.has-alerts .sheet-symbol-alert-icon::after {
    content: '';
    position: absolute;
    top: 1px;
    right: 1px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 2px #0e1524;
}

.sheet-symbol-alert-label {
    font-size: 0.5rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.symbol-alert-scrim {
    position: absolute;
    inset: 0;
    z-index: 70;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: rgba(2, 6, 14, 0.64);
    backdrop-filter: blur(2px);
    transition: opacity 160ms ease, visibility 0s linear 160ms;
}

.symbol-alert-scrim.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0s;
}

.symbol-alert-popover {
    position: absolute;
    inset: 0;
    z-index: 71;
    max-height: none;
    display: flex;
    flex-direction: column;
    visibility: hidden;
    opacity: 0;
    transform: translateX(-10px);
    transform-origin: center;
    overflow: hidden;
    color: var(--text-primary);
    background: linear-gradient(180deg, rgba(17, 25, 42, 0.99), rgba(8, 13, 24, 0.995));
    border: 0;
    border-radius: inherit;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease, visibility 0s linear 160ms;
}

.symbol-alert-popover.active {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
    transition-delay: 0s;
}

.symbol-alert-popover-header {
    min-height: 76px;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
    border-bottom: 1px solid rgba(148, 163, 184, 0.13);
}

.symbol-alert-popover-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 900;
}

.symbol-alert-popover-header p {
    margin: 3px 0 0;
    color: var(--text-secondary);
    font-size: 0.6rem;
    font-weight: 600;
}

.symbol-alert-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.symbol-alert-save-state {
    min-width: 52px;
    color: var(--text-secondary);
    font-size: 0.55rem;
    font-weight: 700;
    text-align: left;
}

.symbol-alert-save-state[data-state="saved"] { color: #34d399; }
.symbol-alert-save-state[data-state="error"] { color: #fb7185; }

.symbol-alert-close {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    background: rgba(148, 163, 184, 0.08);
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 50%;
    cursor: pointer;
}

.symbol-alert-popover-body {
    min-height: 0;
    padding: 14px 16px max(24px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.symbol-alert-all {
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(79, 70, 229, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.23);
    border-radius: 11px;
}

.symbol-alert-all strong,
.symbol-alert-all small { display: block; }
.symbol-alert-all strong { font-size: 0.72rem; }
.symbol-alert-all small {
    margin-top: 3px;
    color: var(--text-secondary);
    font-size: 0.52rem;
    font-weight: 600;
}

.symbol-alert-preferences {
    margin-top: 10px;
    padding-bottom: 10px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.symbol-alert-preference-block { grid-column: 1 / -1; }
.symbol-alert-field-label {
    display: block;
    margin-bottom: 4px;
    color: var(--text-secondary);
    font-size: 0.53rem;
    font-weight: 700;
}

.symbol-alert-segmented {
    padding: 2px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: rgba(148, 163, 184, 0.07);
    border: 1px solid rgba(148, 163, 184, 0.13);
    border-radius: 8px;
}

.symbol-alert-segmented label { cursor: pointer; }
.symbol-alert-segmented input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.symbol-alert-segmented span {
    min-height: 28px;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 0.61rem;
    font-weight: 700;
    transition: color 120ms ease, background-color 120ms ease;
}

.symbol-alert-segmented input:checked + span {
    color: #fff;
    background: rgba(79, 70, 229, 0.9);
}

.symbol-alert-segmented input:focus-visible + span {
    outline: 2px solid rgba(129, 140, 248, 0.8);
    outline-offset: 1px;
}

.symbol-alert-field select {
    width: 100%;
    min-height: 31px;
    padding: 4px 8px;
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.88);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 7px;
    font-family: var(--font-ui);
    font-size: 0.59rem;
    font-weight: 700;
}

.symbol-alert-section {
    margin-top: 10px;
    padding: 12px 13px 4px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 13px;
    background: rgba(15, 23, 42, 0.3);
}
.symbol-alert-section + .symbol-alert-section {
    margin-top: 9px;
}

.symbol-alert-section-title {
    margin: 0 0 4px;
    color: var(--text-secondary);
    font-size: 0.58rem;
    font-weight: 800;
}

.symbol-alert-rule {
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: pointer;
}

.symbol-alert-rule + .symbol-alert-rule {
    border-top: 1px solid rgba(148, 163, 184, 0.07);
}

.symbol-alert-rule-copy { min-width: 0; }
.symbol-alert-rule-label,
.symbol-alert-rule-hint { display: block; }
.symbol-alert-rule-label {
    color: var(--text-primary);
    font-size: 0.66rem;
    font-weight: 700;
}
.symbol-alert-rule-hint {
    margin-top: 2px;
    color: var(--text-secondary);
    font-size: 0.5rem;
    font-weight: 600;
}

.symbol-alert-switch {
    position: relative;
    width: 34px;
    height: 20px;
    display: inline-flex;
    flex: 0 0 34px;
}

.symbol-alert-switch input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.symbol-alert-switch-track {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    background: rgba(100, 116, 139, 0.42);
    transition: background-color 140ms ease;
    pointer-events: none;
}

.symbol-alert-switch-track::after {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e2e8f0;
    transition: transform 140ms ease, background-color 140ms ease;
}

.symbol-alert-switch input:checked + .symbol-alert-switch-track { background: #059669; }
.symbol-alert-switch input:checked + .symbol-alert-switch-track::after {
    transform: translateX(-14px);
    background: #fff;
}
.symbol-alert-switch input:focus-visible + .symbol-alert-switch-track {
    outline: 2px solid rgba(129, 140, 248, 0.9);
    outline-offset: 2px;
}

@media (max-width: 390px) {
    .sheet-symbol-title { gap: 5px; }
    .sheet-symbol-alert-trigger { min-width: 62px; }
    .sheet-symbol-alert-label { font-size: 0.46rem; }
    .sheet-live-price { font-size: 1.22rem; }
    .sheet-change-val { font-size: 0.7rem; }
    .symbol-alert-popover-header { padding: max(12px, env(safe-area-inset-top)) 12px 11px; }
    .symbol-alert-popover-body { padding-inline: 11px; }
}

@media (prefers-reduced-motion: reduce) {
    .symbol-alert-popover,
    .symbol-alert-scrim,
    .symbol-alert-switch-track,
    .symbol-alert-switch-track::after { transition-duration: 0.01ms; }
}
