/* ==========================================================================
   LiveLinkField Component Styles
   Story 28.13: Intake Form UX Improvements - R3: LiveLink Field Indicators

   Features:
   - Cyan left border (3px) for LiveLink fields
   - "Live" badge with pulsing indicator dot
   - Status dot matching field state colors
   - Relative time display for last update
   - Respects prefers-reduced-motion
   ========================================================================== */

/* ========== BASE COMPONENT ========== */

.livelink-field {
    position: relative;
    padding: var(--spacing-sm, 0.5rem) var(--spacing-md, 0.75rem);
    padding-left: calc(var(--spacing-md, 0.75rem) + 3px);
    background-color: var(--medtronic-gray-lightest, #f8f9fa);
    border-radius: var(--radius-md, 6px);
    border-left: 3px solid transparent;
    transition: all var(--transition-base, 0.2s ease);
}

/* ========== LIVE DATA INDICATOR ========== */

.livelink-field.is-live {
    border-left-color: #06b6d4; /* Cyan-500 - Indicates real-time data */
    background-color: rgba(6, 182, 212, 0.04); /* Very subtle cyan tint */
}

.livelink-field.is-live:hover {
    background-color: rgba(6, 182, 212, 0.08);
}

/* ========== FIELD HEADER ========== */

.livelink-field .field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    gap: 8px;
}

.livelink-field .field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== LIVE BADGE ========== */

.livelink-field .live-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #06b6d4; /* Cyan-500 */
    background-color: rgba(6, 182, 212, 0.1);
    border-radius: 100px;
    border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Pulsing indicator dot */
.livelink-field .live-indicator {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #06b6d4; /* Cyan-500 */
    animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* ========== FIELD VALUE ========== */

.livelink-field .field-value {
    display: flex;
    align-items: center;
    gap: 8px;
}

.livelink-field .value-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    line-height: 1.3;
}

/* ========== STATUS DOTS ========== */

.livelink-field .status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background-color: var(--medtronic-gray-medium, #9ca3af);
}

/* Status colors */
.livelink-field.status-good .status-dot {
    background-color: #22c55e; /* Green-500 */
}

.livelink-field.status-warning .status-dot {
    background-color: #f59e0b; /* Amber-500 */
}

.livelink-field.status-danger .status-dot {
    background-color: #ef4444; /* Red-500 */
}

.livelink-field.status-inactive .status-dot {
    background-color: #9ca3af; /* Gray-400 */
}

/* ========== LAST UPDATED ========== */

.livelink-field .last-updated {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted, #9ca3af);
}

.livelink-field .last-updated .oi {
    font-size: 10px;
}

/* ========== STALE DATA INDICATOR ========== */

.livelink-field.stale .live-badge {
    color: #f59e0b; /* Amber-500 */
    background-color: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
}

.livelink-field.stale .live-indicator {
    background-color: #f59e0b;
    animation: none; /* Stop pulsing when stale */
}

.livelink-field.stale .last-updated {
    color: #f59e0b;
}

/* ========== REFRESHING STATE ========== */

.livelink-field.refreshing {
    opacity: 0.7;
}

.livelink-field.refreshing .live-indicator {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* ========== COMPACT MODE ========== */

.livelink-field.compact {
    padding: 6px 10px;
    padding-left: calc(10px + 3px);
}

.livelink-field.compact .field-label {
    font-size: 10px;
}

.livelink-field.compact .value-text {
    font-size: 14px;
}

.livelink-field.compact .status-dot {
    width: 8px;
    height: 8px;
}

.livelink-field.compact .live-badge {
    font-size: 9px;
    padding: 1px 6px;
}

.livelink-field.compact .live-indicator {
    width: 5px;
    height: 5px;
}

.livelink-field.compact .last-updated {
    display: none; /* Hide in compact mode to save space */
}

/* ========== ACCESSIBILITY: REDUCED MOTION ========== */

@media (prefers-reduced-motion: reduce) {
    .livelink-field .live-indicator {
        animation: none;
    }

    .livelink-field.refreshing .live-indicator {
        animation: none;
    }

    .livelink-field {
        transition: none;
    }
}

/* ========== FOCUS STATES ========== */

.livelink-field:focus-visible {
    outline: 2px solid var(--medtronic-blue-interactive, #1010EB);
    outline-offset: 2px;
}

/* ========== GRID LAYOUT HELPERS ========== */

/* For use in a 3-column layout like the TechnicalDataCard header */
.livelink-field-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--spacing-sm, 0.5rem);
}

@media (max-width: 992px) {
    .livelink-field-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .livelink-field-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
}

/* ========== DARK MODE SUPPORT (Future) ========== */

@media (prefers-color-scheme: dark) {
    .livelink-field.is-live {
        background-color: rgba(6, 182, 212, 0.1);
    }

    .livelink-field.is-live:hover {
        background-color: rgba(6, 182, 212, 0.15);
    }
}
