/* Price alerts (app/alerts.js): create/edit dialog, Alerts panel, toasts */

.al-icon-btn {
    display: grid;
    place-items: center;
    flex: none;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}
.al-icon-btn svg { width: 18px; height: 18px; }
.al-icon-btn:hover { background: var(--surface-2); color: var(--text); }

.al-btn {
    height: 38px;
    padding: 0 18px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: 500 14px/1 -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", sans-serif;
    cursor: pointer;
}
.al-btn:hover { background: var(--surface-2); }
.al-btn--primary { border-color: var(--text); background: var(--text); color: var(--surface); }
.al-btn--primary:hover { background: var(--text); opacity: .9; }
.al-btn:disabled { opacity: .5; cursor: default; }

.al-input {
    height: 40px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: 15px/1.2 -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", sans-serif;
    outline: none;
}
.al-input:focus { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.al-input--wide { width: 100%; box-sizing: border-box; }
.al-textarea { display: block; height: 260px; padding: 10px 12px; resize: vertical; line-height: 1.4; }

/* ---- dialog */
.al-back {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    padding: 16px;
    background: rgba(0, 0, 0, 0.45);
}
/* The dialog grows with its content (the backdrop scrolls on short screens), so dropdown menus can
   spill over its edge instead of being clipped. */
.al-dialog {
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    margin: auto 0;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    font: 15px/1.3 -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", sans-serif;
}
.al-dhead { flex: none; display: flex; align-items: center; gap: 8px; padding: 18px 16px 16px 24px; border-bottom: 1px solid var(--border); }
.al-dtitle { flex: 1; min-width: 0; margin: 0; font-size: 20px; font-weight: 600; }
.al-dtitle-in { display: inline-flex; align-items: center; gap: 8px; }
.al-dtitle-in strong { font-weight: 600; }
.al-dbody { flex: 1; padding: 20px 24px; }
.al-dfoot { flex: none; display: flex; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); }
.al-err { flex: 1; color: #ef4444; font-size: 13px; }

.al-grid { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: start; column-gap: 12px; }
.al-grid--rows { row-gap: 14px; align-items: start; }
.al-label { padding-top: 10px; color: var(--text-muted); }
.al-grid--rows .al-label { padding-top: 7px; }
.al-col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.al-values { display: flex; flex-direction: column; gap: 10px; }
.al-chan small { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: 12px; }
.al-sep { height: 1px; margin: 20px 0; border: 0; background: var(--border); }

.al-num { position: relative; display: flex; }
.al-num .al-input { flex: 1; min-width: 0; padding-right: 32px; font-variant-numeric: tabular-nums; }
.al-steps { position: absolute; top: 3px; right: 4px; bottom: 3px; display: flex; flex-direction: column; }
.al-step { flex: 1; width: 24px; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--text-muted); cursor: pointer; }
.al-step svg { width: 14px; height: 14px; }
.al-step:hover { background: var(--surface-2); color: var(--text); }

/* dropdowns */
.al-dd { position: relative; min-width: 0; }
.al-dd-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 40px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.al-dd-btn:hover { border-color: var(--text-muted); }
.al-dd-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.al-dd-icon { flex: none; display: grid; width: 22px; height: 22px; color: var(--text); }
.al-dd-icon svg { width: 22px; height: 22px; }
.al-dd-chev { flex: none; display: grid; width: 18px; height: 18px; color: var(--text-muted); }
.al-dd-chev svg { width: 18px; height: 18px; }
.al-dd--link { justify-self: start; }
.al-dd--link .al-dd-btn { width: auto; height: 32px; padding: 0 6px 0 0; border: 0; gap: 6px; }
.al-dd--link .al-dd-btn:hover .al-dd-text { text-decoration: underline; }
.al-dd-menu {
    position: absolute;
    z-index: 5;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.al-dd--link .al-dd-menu { min-width: 340px; }
.al-dd-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.al-dd-item:hover { background: var(--surface-2); }
.al-dd-item.is-on { background: var(--text); color: var(--surface); }
.al-dd-item.is-on .al-dd-icon, .al-dd-item.is-on small, .al-dd-item.is-on .al-dd-right { color: var(--surface); }
.al-dd-item-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.al-dd-item-text small { color: var(--text-muted); font-size: 13px; }
.al-dd-right { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.al-dd-more {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 4px;
    padding: 10px;
    border: 0;
    border-top: 1px solid var(--border);
    background: none;
    color: var(--text-muted);
    font: 600 12px/1 -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", sans-serif;
    letter-spacing: .06em;
    text-transform: uppercase;
    cursor: pointer;
}
.al-dd-more svg { width: 16px; height: 16px; }
/* Custom expiration: the Go to dialog's date and time fields and calendar (app/goto-dialog.css) */
.al-picker { margin-top: 2px; }
.al-picker .gt-row { margin-bottom: 4px; }
.al-picker .gt-cal-day { height: 34px; font-size: 14px; }
.al-picker .gt-cal-wd { height: 26px; font-size: 12px; }
.al-picker .gt-cal-nav { padding: 4px 0 8px; }
.al-picker .gt-cal-month { font-size: 15px; }

.al-link-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 6px 0;
    border: 0;
    background: none;
    color: var(--text);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.al-link-row svg { flex: none; width: 18px; height: 18px; color: var(--text-muted); }
.al-link-row:hover .al-link-text { text-decoration: underline; }
.al-link-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.al-flabel { display: block; margin: 0 0 8px; color: var(--text-muted); }
.al-flabel + .al-input { margin-bottom: 18px; }
.al-ph { position: relative; display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.al-btn--small { height: 34px; padding: 0 14px; font-size: 14px; }
.al-help {
    display: grid;
    place-items: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    cursor: help;
}
.al-ph-menu { top: auto; bottom: calc(100% + 4px); min-width: 280px; }  /* opens upwards: the button sits at the bottom */
.al-ph-code { font: 13px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.al-note { margin: 14px 0 0; color: var(--text-muted); font-size: 13px; }
.al-note--top { margin: 0; line-height: 1.45; }

.al-check { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0; cursor: pointer; }
/* Checkboxes drawn here, not by the browser: dark with a frame when off, filled with a tick when on. */
.al-check input {
    flex: none;
    display: grid;
    place-items: center;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    border: 1.5px solid var(--text-muted);
    border-radius: 4px;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}
.al-check input::after {
    content: "";
    width: 5px;
    height: 9px;
    margin-top: -2px;
    border: solid var(--surface);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    opacity: 0;
}
.al-check input:checked { border-color: var(--text); background: var(--text); }
.al-check input:checked::after { opacity: 1; }
.al-check:hover input:not(:disabled):not(:checked) { border-color: var(--text); }
.al-check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.al-check input:disabled { border-color: var(--border); background: var(--surface-2); cursor: default; }
.al-check-text { display: flex; flex-direction: column; gap: 3px; }
.al-check-text small { color: var(--text-muted); font-size: 13px; line-height: 1.35; }
.al-check.is-off { cursor: default; opacity: .6; }
.al-sub { margin: 0 0 6px 30px; }
.al-sound { display: flex; gap: 8px; }
.al-sound .al-input { flex: 1; min-width: 0; }
.al-input.al-sub { width: calc(100% - 30px); }

/* ---- panel */
.alerts-panel { position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.al-seg { flex: none; display: flex; gap: 2px; margin: 12px 12px 8px; padding: 3px; border-radius: 10px; background: var(--surface-2); }
.al-seg-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--text-muted);
    font: 500 14px/1 -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", sans-serif;
    cursor: pointer;
}
.al-seg-btn:hover { color: var(--text); }
.al-seg-btn[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); }
.al-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    box-sizing: border-box;
}
.al-bar { flex: none; display: flex; align-items: center; gap: 2px; padding: 0 10px 8px; border-bottom: 1px solid var(--border); }
.al-bar-gap { flex: 1; }
.al-search {
    width: 120px;
    height: 30px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: none;
    color: var(--text);
    font: 13px -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", sans-serif;
    outline: none;
}
.al-search:focus { border-color: var(--accent); }
.al-pop { position: absolute; z-index: 6; min-width: 200px; }
.al-body { flex: 1; min-height: 0; overflow-y: auto; }
.al-empty { padding: 24px 16px; color: var(--text-muted); font-size: 13px; text-align: center; }
.al-empty p { margin: 0 0 14px; line-height: 1.45; }
.al-list { margin: 0; padding: 0; list-style: none; }
.al-item { position: relative; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.al-item:hover { background: var(--surface-2); }
.al-item--log { cursor: default; }
.al-title-line { font-size: 14px; line-height: 1.35; overflow-wrap: anywhere; }
.al-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; color: var(--text-muted); font-size: 12.5px; }
.al-meta .al-sym { font-weight: 500; }
.al-dot { opacity: .7; }
.al-state.is-active { color: #26a69a; }
.al-state.is-paused { color: var(--text-muted); }
.al-state.is-triggered { color: #f0b90b; }
.al-state.is-expired { color: #ef4444; }
.al-actions { position: absolute; top: 8px; right: 10px; display: none; gap: 2px; padding: 2px; border-radius: 8px; background: var(--surface); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); }
.al-item:hover .al-actions, .al-item:focus-within .al-actions { display: flex; }

/* ---- toasts */
.al-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); }
.al-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 8px 12px 14px;
    border: 1px solid var(--border);
    border-left: 3px solid #f0b90b;
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    font: 13px/1.35 -apple-system, BlinkMacSystemFont, Inter, "Segoe UI", sans-serif;
    animation: al-in .2s ease;
    transition: opacity .3s, transform .3s;
}
.al-toast.is-leaving { opacity: 0; transform: translateX(16px); }
@keyframes al-in { from { opacity: 0; transform: translateY(8px); } }
.al-toast-icon { flex: none; display: grid; width: 22px; height: 22px; color: #f0b90b; }
.al-toast-icon svg { width: 22px; height: 22px; }
.al-toast-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.al-toast-msg { overflow-wrap: anywhere; }
.al-toast-time { color: var(--text-muted); font-size: 12px; }

@media (max-width: 560px) {
    .al-back { padding: 8px; align-items: flex-end; }
    .al-grid { grid-template-columns: 1fr; row-gap: 6px; }
    .al-grid--rows { row-gap: 4px; }
    .al-grid--rows .al-label { margin-top: 8px; }
    .al-label { padding-top: 0; }
    .al-dbody { padding: 16px; }
    .al-dd--link .al-dd-menu { min-width: 0; width: calc(100vw - 48px); }
}

/* ---- small in-app dialogs (app/dialog.js): replace the browser's prompt / confirm / alert */
.qd-back { align-items: center; z-index: 95; }
.qd-dialog { width: min(420px, 100%); }
.qd-message { margin: 0 0 14px; color: var(--text-muted); font-size: 14px; line-height: 1.5; white-space: pre-line; overflow-wrap: anywhere; }
.qd-field { position: relative; display: flex; align-items: center; }
.qd-input { flex: 1; width: 100%; box-sizing: border-box; font-variant-numeric: tabular-nums; }
.qd-suffix { position: absolute; right: 12px; color: var(--text-muted); font-size: 13px; pointer-events: none; }
.qd-field .qd-input { padding-right: 56px; }
/* No browser spinner arrows: values are typed (the arrow keys still step them). */
.qd-input { -moz-appearance: textfield; appearance: textfield; }
.qd-input::-webkit-inner-spin-button, .qd-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.qd-input:disabled { opacity: .45; }
.qd-check { align-items: center; margin-top: 12px; }
.qd-check input { margin: 0; }
.qd-err { margin: 8px 0 0; min-height: 1em; }
.qd-err:empty { display: none; }
.qd-spacer { flex: 1; }
.qd-danger { border-color: #ef4444 !important; background: #ef4444 !important; color: #fff !important; }
