/* livemonitor.css - Scanner section in Automation */

/* ===== LIVE MONITORS LIST ===== */

.live-monitors-section {
    margin-top: 0;
    padding-top: 0;
}

.live-monitors-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

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

.live-monitors-header h4 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.live-monitors-header h4 .live-dot {
    display: inline-block;
}

#live-monitors-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== MONITOR CARD ===== */

.live-monitor-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: all var(--transition);
    border-left: 3px solid var(--success);
    cursor: pointer;
}

.live-monitor-card:active {
    transform: scale(0.98);
}

.live-monitor-card.live-paused {
    border-left-color: var(--text-tertiary);
    opacity: 0.7;
}

.live-monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.live-monitor-status {
    display: flex;
    align-items: center;
    gap: 6px;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot-green {
    background: var(--success);
    box-shadow: 0 0 6px rgba(74, 140, 111, 0.4);
    animation: live-pulse 2s ease-in-out infinite;
}

.dot-gray {
    background: var(--text-tertiary);
}

.live-status-text {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.live-monitor-actions {
    display: flex;
    gap: 4px;
}

.live-monitor-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.live-monitor-query {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.4;
}

.live-monitor-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.live-raw-count {
    color: var(--primary);
    font-weight: 600;
}

/* ===== ALERT BADGE ===== */

.live-alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #B8860B;
    color: white;
    font-size: 11px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    line-height: 1;
    animation: alertPulse 2s ease-in-out infinite;
}

@keyframes alertPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(184, 134, 11, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(184, 134, 11, 0); }
}

/* ===== ALERT MODAL LIST ===== */

.monitor-alerts-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 50vh;
    overflow-y: auto;
}

.monitor-alert-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius);
}

.monitor-alert-icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.monitor-alert-content {
    flex: 1;
    min-width: 0;
}

.monitor-alert-reason {
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
    margin: 0;
}

.monitor-alert-date {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    display: block;
}

/* ===== EMPTY STATE ===== */

.live-empty {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-tertiary);
}

.live-empty svg {
    margin-bottom: 12px;
}

.live-empty p {
    font-size: 14px;
    max-width: 280px;
    margin: 0 auto;
    line-height: 1.5;
}

/* ===== CREATE MODAL ===== */

.live-monitor-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.live-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.live-form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.live-form-group input,
.live-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    font-size: 14px;
    color: var(--text);
    transition: border-color var(--transition);
    box-sizing: border-box;
}

.live-form-group input:focus,
.live-form-group textarea:focus {
    border-color: var(--primary);
    outline: none;
}

.live-form-group textarea {
    resize: vertical;
    min-height: 70px;
}

.live-form-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* Template file section */

.live-template-section {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.live-template-section:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.04);
}

.live-template-section svg {
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.live-template-section p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.live-template-section span {
    font-size: 11px;
    color: var(--text-tertiary);
}

#live-template-file-info {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    background: rgba(34, 197, 94, 0.08);
    border-radius: var(--radius);
    margin-top: 8px;
}

.live-template-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.live-template-cols {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== RESPONSIVE ===== */

@media (max-width: 768px) {
    .live-monitor-meta {
        gap: 8px;
    }

    .live-monitors-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* ===== NOTIFICATION PICKER ===== */
.btn-notification-active {
    position: relative;
}
.btn-notification-active::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #B8860B;
}

.notif-type-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.notif-type-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 14px;
    color: var(--text);
}
.notif-type-option input[type="radio"] {
    display: none;
}
.notif-type-option.selected {
    border-color: #B8860B;
    background: rgba(184, 134, 11, 0.08);
}
.notif-type-option svg {
    color: var(--text-secondary);
    flex-shrink: 0;
}
.notif-type-option.selected svg {
    color: #B8860B;
}

/* ===== FREQUENCY PICKER ===== */
.freq-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.freq-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.15s ease;
}
.freq-option input[type="radio"] {
    display: none;
}
.freq-option.selected {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.06);
}
.freq-option-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
}
.freq-option-label {
    font-size: 15px;
    font-weight: 500;
    color: var(--text);
}
.freq-option-cost {
    font-size: 12px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 6px;
}
.cost-free {
    color: var(--success);
    background: rgba(74, 140, 111, 0.1);
}
.cost-low {
    color: var(--primary);
    background: rgba(45, 91, 227, 0.1);
}
.cost-medium {
    color: #92400E;
    background: rgba(217, 119, 6, 0.1);
}
.cost-high {
    color: var(--error);
    background: rgba(192, 96, 74, 0.1);
}

/* ===== IN-APP ALERT BANNER ===== */
.alert-notification-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    background: linear-gradient(135deg, #B8860B, #92400E);
    color: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    animation: alertSlideIn 0.3s ease;
}
@keyframes alertSlideIn {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}
.alert-notification-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.alert-notification-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.alert-notification-content strong {
    font-size: 14px;
    font-weight: 700;
}
.alert-notification-content span {
    font-size: 13px;
    opacity: 0.9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.alert-notification-close {
    background: none;
    border: none;
    color: white;
    opacity: 0.7;
    cursor: pointer;
    padding: 4px;
    flex-shrink: 0;
}
.alert-notification-close:active {
    opacity: 1;
}

/* ===== MONITOR DETAIL PANEL ===== */

.monitor-detail-panel {
    display: none;
    flex-direction: column;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 16px;
}

.monitor-detail-panel.open {
    display: flex;
}

.monitor-detail-top-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    flex-shrink: 0;
}

.monitor-detail-content {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}

.monitor-detail-update-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    border-radius: 12px;
}

.monitor-detail-section {
    margin-bottom: 24px;
}

.monitor-detail-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.monitor-detail-empty {
    font-size: 14px;
    color: var(--text-tertiary);
    font-style: italic;
}

/* Alert cards - yellow style */
.monitor-detail-alert-card {
    background: #FEF3C7;
    border-left: 3px solid #B8860B;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 8px;
    cursor: pointer;
}

.monitor-detail-alert-card:active {
    opacity: 0.7;
}

.monitor-detail-alert-reason {
    font-size: 14px;
    font-weight: 500;
    color: #92400E;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.monitor-detail-alert-date {
    font-size: 12px;
    color: #B45309;
    margin-top: 4px;
}

[data-theme="dark"] .monitor-detail-alert-card {
    background: rgba(245, 158, 11, 0.1);
}

[data-theme="dark"] .monitor-detail-alert-reason {
    color: #FCD34D;
}

[data-theme="dark"] .monitor-detail-alert-date {
    color: #FBBF24;
}

/* ===== MONITOR EDIT POPUP ===== */

.monitor-edit-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: background 0.25s ease;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.monitor-edit-overlay.monitor-edit-overlay-visible {
    background: rgba(0, 0, 0, 0.45);
}

.monitor-edit-dialog {
    background: var(--bg);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 560px;
    padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 16px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 85vh;
    overflow-y: auto;
}

.monitor-edit-overlay.monitor-edit-overlay-visible .monitor-edit-dialog {
    transform: translateY(0);
}

.monitor-edit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.monitor-edit-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.monitor-edit-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 4px;
}

.monitor-edit-footer .btn {
    padding: 10px 22px;
    font-size: 14px;
}

/* Archive content */
.monitor-detail-archive-text {
    font-size: 14px;
    color: var(--text);
    line-height: 1.6;
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 14px;
    margin: 0;
}

/* Mobile: detail becomes fullscreen overlay */
@media (max-width: 768px) {
    .monitor-detail-panel.open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        margin: 0;
        border-radius: 0;
        border: none;
        touch-action: pan-y;
        overscroll-behavior: none;
    }

    .monitor-detail-content {
        max-height: none;
        flex: 1;
        touch-action: pan-y;
    }
}

/* ===== MONITOR EXAMPLES MODAL ===== */

.monitor-example-item {
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.2s;
}
.monitor-example-item:last-child {
    margin-bottom: 0;
}
.monitor-example-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    cursor: pointer;
}
.monitor-example-header:active {
    transform: scale(0.98);
}
.monitor-example-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.monitor-example-icon svg {
    width: 20px;
    height: 20px;
}
.monitor-example-info {
    flex: 1;
    min-width: 0;
}
.monitor-example-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}
.monitor-example-info p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.monitor-example-chevron {
    flex-shrink: 0;
    color: var(--text-tertiary);
    transition: transform 0.2s;
}
.monitor-example-item.expanded .monitor-example-chevron {
    transform: rotate(180deg);
}
.monitor-example-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding: 0 14px;
}
.monitor-example-item.expanded .monitor-example-detail {
    max-height: 350px;
    padding: 0 14px 14px;
}
.monitor-example-desc {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 10px;
}
.monitor-example-fields {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.monitor-example-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border-radius: 8px;
}
.monitor-example-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.monitor-example-field-value {
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
}
.monitor-example-use-btn {
    width: 100%;
    justify-content: center;
    gap: 6px;
    margin-top: 4px;
}

/* ===== MONITOR EDIT DIALOG - LARGER ===== */

.monitor-edit-dialog {
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
}

.monitor-edit-body textarea {
    min-height: 120px;
    font-size: 16px;
    resize: none;
    width: 100%;
}

/* ===== ALERT CHATBOT ===== */

.alert-condition-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.3;
}

[data-theme="dark"] .alert-condition-badge {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.alert-condition-badge svg {
    flex-shrink: 0;
}

.alert-chatbot-container {
    border: 1px solid var(--border-color, var(--border));
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.alert-chatbot-messages {
    max-height: 200px;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert-chat-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.alert-chat-bot {
    align-self: flex-start;
    background: var(--bg-primary, var(--bg));
    border: 1px solid var(--border-color, var(--border));
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.alert-chat-user {
    align-self: flex-end;
    background: var(--accent-color, var(--primary));
    color: white;
    border-bottom-right-radius: 4px;
}

.alert-chat-typing .typing-dots {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}

.alert-chat-typing .typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.alert-chat-typing .typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.alert-chat-typing .typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

.alert-chatbot-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid var(--border-color, var(--border));
    background: var(--bg-primary, var(--bg));
}

.alert-chatbot-input-row input {
    flex: 1;
    border: 1px solid var(--border-color, var(--border));
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 14px;
    background: var(--bg-secondary);
    color: var(--text);
    outline: none;
}

.alert-chatbot-input-row input:focus {
    border-color: var(--accent-color, var(--primary));
}

.alert-chatbot-send-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Compact notification type options for edit popup */
.notif-type-options-compact {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.notif-type-option-compact {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 12px;
    color: var(--text);
    text-align: center;
}

.notif-type-option-compact input[type="radio"] {
    display: none;
}

.notif-type-option-compact.selected {
    border-color: #B8860B;
    background: rgba(184, 134, 11, 0.08);
}

.notif-type-option-compact svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.notif-type-option-compact.selected svg {
    color: #B8860B;
}

/* ===== HISTORY ACCORDION ===== */

.history-accordion {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
}

.history-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    background: var(--bg-secondary);
    transition: background 0.15s;
}

.history-accordion-header:active {
    background: var(--bg-tertiary, var(--bg-secondary));
}

.history-accordion-chevron {
    color: var(--text-tertiary);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.history-accordion.expanded .history-accordion-chevron {
    transform: rotate(180deg);
}

.history-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.history-accordion.expanded .history-accordion-body {
    max-height: 600px;
    overflow-y: auto;
}

.history-item {
    padding: 10px 14px;
    border-top: 1px solid var(--border);
}

.history-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.history-period {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    background: rgba(79, 70, 229, 0.08);
    padding: 2px 8px;
    border-radius: 4px;
}

.history-item-date {
    font-size: 11px;
    color: var(--text-tertiary);
}

.history-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin: 0;
}
