/**
 * Alert System Styles (ALERT-006 / Phase 10)
 * 
 * Audible alarm visual feedback and alert UI components.
 * 
 * Spec: specs/010-alert-notification-system/design.md
 */

/* ===================================================================
   ALERT PANEL CONTAINER
   =================================================================== */

.alert-panel {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 420px;
    max-height: calc(100vh - 100px);
    background-color: var(--bg-secondary, #1e2130);
    border: 1px solid var(--border-color, #2d3350);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.alert-panel.collapsed {
    transform: translateX(calc(100% + 20px));
    opacity: 0;
    pointer-events: none;
}

.alert-panel-header {
    padding: 12px 16px;
    background-color: var(--bg-tertiary, #15171e);
    border-bottom: 1px solid var(--border-color, #2d3350);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-panel-title-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background-color: #dc2626;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
}

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

.alert-priority-badges {
    display: flex;
    gap: 4px;
}

.alert-priority-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    cursor: help;
}

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-secondary, #8892b0);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-icon:hover {
    background-color: var(--bg-hover, #2d3350);
    color: var(--text-primary, #ffffff);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.alert-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
}

/* Custom scrollbar for alert panel */
.alert-panel-body::-webkit-scrollbar {
    width: 8px;
}

.alert-panel-body::-webkit-scrollbar-track {
    background: var(--bg-secondary, #1e2130);
}

.alert-panel-body::-webkit-scrollbar-thumb {
    background: var(--border-color, #2d3350);
    border-radius: 4px;
}

.alert-panel-body::-webkit-scrollbar-thumb:hover {
    background: #4a5568;
}

.alert-section {
    margin-bottom: 4px;
}

.alert-section-header {
    padding: 8px 16px;
    background-color: var(--bg-tertiary, #15171e);
    border-bottom: 1px solid var(--border-color, #2d3350);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.alert-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary, #8892b0);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alert-section-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary, #6b7280);
    background-color: var(--bg-hover, #2d3350);
    padding: 2px 6px;
    border-radius: 10px;
}

.alert-list {
    padding: 8px;
}

.alert-panel-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary, #8892b0);
}

.alert-panel-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.alert-panel-empty p {
    margin: 0;
    font-size: 14px;
}

.alert-panel-footer {
    padding: 12px 16px;
    background-color: var(--bg-tertiary, #15171e);
    border-top: 1px solid var(--border-color, #2d3350);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

/* ===================================================================
   ALERT PANEL INDICATOR (Collapsed State)
   =================================================================== */

.alert-panel-indicator {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 56px;
    height: 56px;
    background-color: var(--bg-secondary, #1e2130);
    border: 1px solid var(--border-color, #2d3350);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.2s ease;
}

.alert-panel-indicator:hover {
    background-color: var(--bg-hover, #2d3350);
    transform: scale(1.05);
}

.alert-panel-indicator svg {
    width: 28px;
    height: 28px;
    color: var(--text-primary, #ffffff);
}

.alert-indicator-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background-color: #dc2626;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-secondary, #1e2130);
}

/* ===================================================================
   ALERT ROWS
   =================================================================== */

.alert-row {
    padding: 12px;
    margin-bottom: 8px;
    background-color: var(--bg-hover, #252836);
    border-left: 4px solid var(--alert-border, #555555);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.alert-row:hover {
    background-color: var(--bg-active, #2d3350);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.alert-row.acknowledged {
    opacity: 0.7;
}

.alert-row.resolved {
    opacity: 0.5;
}

.alert-row-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.alert-priority-wrapper {
    display: flex;
    gap: 6px;
    align-items: center;
}

.alert-priority {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 3px;
    line-height: 1;
}

.alert-timestamp {
    font-size: 11px;
    color: var(--text-tertiary, #6b7280);
}

.alert-content {
    margin-bottom: 8px;
}

.alert-title {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.alert-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-secondary, #8892b0);
}

.alert-title-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
}

.alert-message {
    font-size: 13px;
    color: var(--text-primary, #ffffff);
    line-height: 1.5;
    margin-bottom: 6px;
}

.alert-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: var(--text-secondary, #8892b0);
    margin-top: 6px;
}

.alert-detail-item {
    padding: 2px 6px;
    background-color: var(--bg-tertiary, #15171e);
    border-radius: 3px;
}

.alert-detail-item strong {
    color: var(--text-tertiary, #6b7280);
    font-weight: 500;
}

.alert-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.alert-ack-info,
.alert-resolved-info {
    font-size: 11px;
    color: var(--text-secondary, #8892b0);
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    width: 100%;
    padding: 6px;
    background-color: var(--bg-tertiary, #15171e);
    border-radius: 3px;
    margin-top: 4px;
}

.alert-ack-label,
.alert-resolved-label {
    font-weight: 500;
    color: var(--text-tertiary, #6b7280);
}

.alert-ack-user,
.alert-resolved-user {
    font-weight: 600;
    color: var(--text-primary, #ffffff);
}

.alert-ack-time,
.alert-resolved-time {
    color: var(--text-tertiary, #6b7280);
}

.alert-resolved-notes {
    width: 100%;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px solid var(--border-color, #2d3350);
    font-style: italic;
}

/* ===================================================================
   PRIORITY-SPECIFIC STYLES
   =================================================================== */

/* CRITICAL alerts (P0) - RED */
.alert-row.priority-critical {
    border-left-color: #dc2626;
    background-color: rgba(220, 38, 38, 0.08);
}

.alert-priority.priority-critical {
    background-color: #dc2626;
    color: #ffffff;
}

/* HIGH alerts (P1) - ORANGE */
.alert-row.priority-high {
    border-left-color: #ea580c;
}

.alert-priority.priority-high {
    background-color: #ea580c;
    color: #ffffff;
}

/* MEDIUM alerts (P2) - YELLOW */
.alert-row.priority-medium {
    border-left-color: #eab308;
}

.alert-priority.priority-medium {
    background-color: #eab308;
    color: #000000;
}

/* LOW alerts (P3) - BLUE */
.alert-row.priority-low {
    border-left-color: #3b82f6;
}

.alert-priority.priority-low {
    background-color: #3b82f6;
    color: #ffffff;
}

/* INFO alerts (P4) - GRAY */
.alert-row.priority-info {
    border-left-color: #6b7280;
}

.alert-priority.priority-info {
    background-color: #6b7280;
    color: #ffffff;
}

/* ===================================================================
   AUDIBLE ALARM ANIMATION (ALERT-006)
   =================================================================== */

/**
 * Pulse animation for CRITICAL alerts with active audible alarms
 * 
 * Applied when escalation timer reaches 30 seconds and alarm is triggered.
 * Provides visual feedback that alarm is sounding.
 * 
 * Animation cycle: 1.5 seconds
 * - 0.0s: opacity 1.0 (full brightness)
 * - 0.75s: opacity 0.6 (dimmed - 40% reduction)
 * - 1.5s: opacity 1.0 (full brightness)
 * 
 * Spec: specs/010-alert-notification-system/requirements.md (REQ-ALERT-006)
 */
@keyframes pulse {
    0% {
        opacity: 1.0;
        transform: scale(1.0);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.02);
    }
    100% {
        opacity: 1.0;
        transform: scale(1.0);
    }
}

.alarm-active {
    animation: pulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 12px rgba(220, 38, 38, 0.6);
}

/* Additional visual emphasis for alarming alerts */
.alarm-active .alert-priority {
    animation: pulse-text 1.5s ease-in-out infinite;
}

@keyframes pulse-text {
    0% {
        text-shadow: 0 0 0 rgba(220, 38, 38, 0);
    }
    50% {
        text-shadow: 0 0 8px rgba(220, 38, 38, 0.8);
    }
    100% {
        text-shadow: 0 0 0 rgba(220, 38, 38, 0);
    }
}

/* ===================================================================
   ALERT STATUS BADGES
   =================================================================== */

.alert-status {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 2px;
    margin-left: 8px;
}

.alert-status.status-active {
    background-color: #dc2626;
    color: #ffffff;
}

.alert-status.status-acknowledged {
    background-color: #eab308;
    color: #000000;
}

.alert-status.status-resolved {
    background-color: #22c55e;
    color: #ffffff;
}

/* ===================================================================
   ALERT BUTTONS
   =================================================================== */

.btn-alert {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-alert:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.btn-alert:active {
    transform: translateY(0);
}

.btn-acknowledge {
    background-color: #eab308;
    color: #000000;
}

.btn-resolve {
    background-color: #22c55e;
    color: #ffffff;
}

.btn-silence {
    background-color: #6b7280;
    color: #ffffff;
}

.btn-alert:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===================================================================
   ALERT ESCALATION TIMER
   =================================================================== */

.alert-escalation-timer {
    font-size: 11px;
    color: #dc2626;
    font-weight: 600;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.alert-escalation-timer::before {
    content: "⚠";
    font-size: 14px;
}

.alert-escalation-timer.timer-critical {
    animation: pulse 1s ease-in-out infinite;
}

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

@media (max-width: 768px) {
    .alert-panel {
        width: calc(100vw - 40px);
        right: 20px;
        left: 20px;
        top: 60px;
    }
}

@media (max-width: 480px) {
    .alert-panel {
        width: 100vw;
        right: 0;
        left: 0;
        top: 0;
        max-height: 100vh;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
}

/* ===================================================================
   MODAL STYLES
   =================================================================== */

.modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: var(--bg-secondary, #1e2130);
    border: 1px solid var(--border-color, #2d3350);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 16px 20px;
    background-color: var(--bg-tertiary, #15171e);
    border-bottom: 1px solid var(--border-color, #2d3350);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary, #8892b0);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background-color: var(--bg-hover, #2d3350);
    color: var(--text-primary, #ffffff);
}

.modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 20px;
    background-color: var(--bg-tertiary, #15171e);
    border-top: 1px solid var(--border-color, #2d3350);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary, #ffffff);
    margin-bottom: 6px;
}

.form-group label .required {
    color: #dc2626;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    background-color: var(--bg-hover, #2d3350);
    border: 1px solid var(--border-color, #2d3350);
    border-radius: 4px;
    color: var(--text-primary, #ffffff);
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: #4a9eff;
    box-shadow: 0 0 0 2px rgba(74, 158, 255, 0.2);
}

.form-control::placeholder {
    color: var(--text-tertiary, #6b7280);
}

.form-text {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-tertiary, #6b7280);
}

.btn {
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: #4a9eff;
    color: #ffffff;
}

.btn-secondary {
    background-color: transparent;
    color: var(--text-secondary, #8892b0);
    border: 1px solid var(--border-color, #2d3350);
}

.btn-secondary:hover {
    background-color: var(--bg-hover, #2d3350);
    color: var(--text-primary, #ffffff);
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* ===================================================================
   ACCESSIBILITY
   =================================================================== */

/* Reduced motion for users with vestibular disorders */
@media (prefers-reduced-motion: reduce) {
    .alarm-active,
    .alarm-active .alert-priority,
    .alert-escalation-timer.timer-critical {
        animation: none;
    }
    
    /* Fallback: solid visual indicator without animation */
    .alarm-active {
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.5);
        border: 2px solid #dc2626;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .alert-row {
        border-width: 2px;
    }
    
    .alarm-active {
        border-width: 3px;
    }
}
