/* ═══════════════════════════════════════════════════════
   🔔 PRICE ALERTS — Feature 12.1
   Professional alert system styling
   ═══════════════════════════════════════════════════════ */

/* ── Page Header ── */
.alerts-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.alerts-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary, #fff);
    display: flex;
    align-items: center;
    gap: 10px;
}
.alerts-title svg {
    width: 26px;
    height: 26px;
    color: var(--primary-orange, #f97316);
}
.alerts-header-actions {
    display: flex;
    gap: 8px;
}

/* ── Tab Bar ── */
.alerts-tabs {
    display: flex;
    gap: 4px;
    background: var(--card-bg, rgba(30,41,59,0.5));
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
}
.alerts-tab {
    flex: 1;
    min-width: 100px;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted, #94a3b8);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
    text-align: center;
}
.alerts-tab.active {
    background: var(--primary, #6366f1);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.alerts-tab .tab-count {
    display: inline-block;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    border-radius: 9px;
    background: rgba(255,255,255,0.15);
    font-size: 11px;
    font-weight: 700;
    margin-left: 6px;
    padding: 0 5px;
    text-align: center;
}
.alerts-tab.active .tab-count {
    background: rgba(255,255,255,0.25);
}

/* ── Tab Content Panels ── */
.alerts-panel {
    display: none;
}
.alerts-panel.active {
    display: block;
    animation: alertFadeIn 0.25s ease;
}
@keyframes alertFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Alert Card ── */
.alert-card {
    background: var(--card-bg, rgba(30,41,59,0.6));
    border: 1px solid var(--border-color, rgba(148,163,184,0.12));
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    position: relative;
}
.alert-card:hover {
    border-color: rgba(99,102,241,0.3);
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
.alert-card.alert-triggered {
    border-left: 3px solid #10b981;
}
.alert-card.alert-inactive {
    opacity: 0.55;
}

.alert-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.alert-stock-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-stock-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-tertiary, #1e293b);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--primary, #6366f1);
    overflow: hidden;
}
.alert-stock-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.alert-stock-name {
    display: flex;
    flex-direction: column;
}
.alert-stock-code {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
.alert-stock-label {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}

.alert-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Toggle Switch ── */
.alert-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.alert-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.alert-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--bg-tertiary, #334155);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
}
.alert-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    left: 3px;
    top: 3px;
    transition: transform 0.3s;
}
.alert-toggle input:checked + .alert-toggle-slider {
    background: #10b981;
}
.alert-toggle input:checked + .alert-toggle-slider::before {
    transform: translateX(20px);
}

/* ── Alert Body (condition / price info) ── */
.alert-card-body {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.alert-condition {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--bg-tertiary, rgba(15,23,42,0.6));
    border-radius: 10px;
    font-size: 13px;
    flex: 1;
    min-width: 200px;
}
.alert-condition-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.alert-condition-icon.above {
    background: rgba(16,185,129,0.15);
    color: #10b981;
}
.alert-condition-icon.below {
    background: rgba(239,68,68,0.15);
    color: #ef4444;
}
.alert-condition-text {
    display: flex;
    flex-direction: column;
}
.alert-condition-label {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}
.alert-condition-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
.alert-current-price {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    padding: 6px 12px;
    background: var(--bg-tertiary, rgba(15,23,42,0.4));
    border-radius: 8px;
    white-space: nowrap;
}

/* ── Alert Footer (meta info) ── */
.alert-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color, rgba(148,163,184,0.08));
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}
.alert-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}
.alert-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}
.alert-delete-btn:hover {
    color: #ef4444;
    background: rgba(239,68,68,0.1);
}

/* ── Triggered Badge ── */
.alert-triggered-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(16,185,129,0.12);
    color: #10b981;
}
.alert-triggered-at {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
}

/* ── Create Alert Modal ── */
.alert-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.alert-modal-overlay.show {
    display: flex;
}
.alert-modal {
    background: var(--bg-modal, #27272a);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px 20px 32px;
    animation: alertModalSlideUp 0.3s ease;
}
@keyframes alertModalSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.alert-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.alert-modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary, #fff);
}
.alert-modal-close {
    background: none;
    border: none;
    color: var(--text-muted, #94a3b8);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

/* ── Form ── */
.alert-form-group {
    margin-bottom: 18px;
}
.alert-form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #cbd5e1);
    margin-bottom: 8px;
}
.alert-form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color, rgba(148,163,184,0.2));
    border-radius: 12px;
    background: var(--bg-tertiary, #0f172a);
    color: var(--text-primary, #fff);
    font-size: 15px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.alert-form-input:focus {
    border-color: var(--primary, #6366f1);
}
.alert-form-input::placeholder {
    color: var(--text-muted, #475569);
}

/* ── Condition Selector ── */
.alert-condition-selector {
    display: flex;
    gap: 8px;
}
.alert-condition-option {
    flex: 1;
    padding: 14px;
    border: 2px solid var(--border-color, rgba(148,163,184,0.15));
    border-radius: 12px;
    background: var(--bg-tertiary, #0f172a);
    cursor: pointer;
    transition: all 0.25s;
    text-align: center;
}
.alert-condition-option:hover {
    border-color: rgba(99,102,241,0.4);
}
.alert-condition-option.selected {
    border-color: var(--primary, #6366f1);
    background: rgba(99,102,241,0.08);
}
.alert-condition-option.selected.above {
    border-color: #10b981;
    background: rgba(16,185,129,0.08);
}
.alert-condition-option.selected.below {
    border-color: #ef4444;
    background: rgba(239,68,68,0.08);
}
.alert-cond-icon {
    font-size: 24px;
    margin-bottom: 4px;
}
.alert-cond-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #fff);
}
.alert-cond-desc {
    font-size: 11px;
    color: var(--text-muted, #94a3b8);
    margin-top: 2px;
}

/* ── Stock Search in Modal ── */
.alert-stock-search-result {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg, #1e293b);
    border: 1px solid var(--border-color, rgba(148,163,184,0.2));
    border-radius: 12px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    margin-top: 4px;
}
.alert-stock-search-result.show {
    display: block;
}
.alert-search-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: background 0.15s;
}
.alert-search-item:hover {
    background: rgba(99,102,241,0.08);
}
.alert-search-item-code {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary, #fff);
    min-width: 56px;
}
.alert-search-item-name {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.alert-search-item-price {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #cbd5e1);
    margin-left: auto;
    white-space: nowrap;
}

/* ── Submit Button ── */
.alert-submit-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 8px;
}
.alert-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
}
.alert-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Quick Price Info in Modal ── */
.alert-price-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-tertiary, rgba(15,23,42,0.6));
    border-radius: 12px;
    margin-bottom: 18px;
}
.alert-price-current {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary, #fff);
}
.alert-price-change {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 8px;
}
.alert-price-change.up {
    background: rgba(16,185,129,0.12);
    color: #10b981;
}
.alert-price-change.down {
    background: rgba(239,68,68,0.12);
    color: #ef4444;
}

/* ── Create FAB ── */
.alert-fab {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99,102,241,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: transform 0.2s;
}
.alert-fab:hover {
    transform: scale(1.08);
}

/* ── Empty State ── */
.alerts-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted, #94a3b8);
}
.alerts-empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}
.alerts-empty h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #fff);
    margin-bottom: 6px;
}
.alerts-empty p {
    font-size: 13px;
    line-height: 1.5;
}

/* ── Loading Spinner ── */
.alerts-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted, #94a3b8);
    font-size: 13px;
}
.alerts-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(99,102,241,0.2);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: alertSpin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes alertSpin {
    to { transform: rotate(360deg); }
}

/* ── Toast ── */
.alert-toast {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    z-index: 99999;
    transition: bottom 0.4s cubic-bezier(0.4,0,0.2,1);
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.alert-toast.show {
    bottom: 90px;
}
.alert-toast.success {
    background: #065f46;
    color: #6ee7b7;
    border: 1px solid rgba(16,185,129,0.3);
}
.alert-toast.error {
    background: #7f1d1d;
    color: #fca5a5;
    border: 1px solid rgba(239,68,68,0.3);
}
.alert-toast.info {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid rgba(99,102,241,0.3);
}

/* ── Set Alert Button (stock-detail & watchlist inline) ── */
.set-alert-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: 10px;
    background: rgba(99,102,241,0.08);
    color: #a5b4fc;
    cursor: pointer;
    transition: all 0.2s;
}
.set-alert-btn:hover {
    background: rgba(99,102,241,0.16);
    border-color: rgba(99,102,241,0.5);
    color: #c7d2fe;
}
.set-alert-btn svg {
    width: 20px;
    height: 20px;
}

/* ── Responsive ── */
@media (max-width: 480px) {
    .alert-modal {
        border-radius: 16px 16px 0 0;
        padding: 20px 16px 28px;
    }
    .alert-condition-selector {
        flex-direction: column;
    }
    .alert-card-body {
        flex-direction: column;
        align-items: stretch;
    }
    .alert-condition {
        min-width: unset;
    }
}
