/* ============================================
   WeCare Developer Dashboard - Consolidated Styles
   ============================================ */

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    font-size: 1rem;
    opacity: 0.9;
}

/* ============================================
   Tab Navigation
   ============================================ */
.tab-nav {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.tab-nav-link {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.2s;
    cursor: pointer;
}

.tab-nav-link:hover {
    background: rgba(255, 255, 255, 0.3);
}

.tab-nav-link.active {
    background: white;
    color: #667eea;
}

/* Tab Content */
.tab-content {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Controls Bar
   ============================================ */
.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 0 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-primary {
    background: white;
    color: #667eea;
    border: 2px solid white;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
    background: transparent;
    color: white;
    border: 2px solid white;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: white;
    color: #667eea;
}

.last-updated {
    color: white;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Device Selector */
.device-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    padding: 8px 16px;
    border-radius: 8px;
}

.device-selector-wrapper label {
    font-weight: 600;
    color: #667eea;
}

.device-selector-wrapper select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid #667eea;
    font-size: 14px;
    font-weight: 500;
    background: white;
    color: #333;
    cursor: pointer;
    min-width: 180px;
}

.device-selector-wrapper select:focus {
    outline: none;
    border-color: #764ba2;
}

/* ============================================
   Statistics Grid
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.stat-label {
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
}

/* ============================================
   Analytics Section
   ============================================ */
.analytics-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    margin-bottom: 25px;
}

.analytics-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #333;
}

.analytics-section h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #555;
}

.section-description {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

/* Configuration Panel */
.config-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.config-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.config-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.config-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #667eea;
}

/* ============================================
   Drain Stats Grid
   ============================================ */
.drain-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.drain-stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 20px;
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.drain-stat-card:hover {
    transform: translateY(-3px);
}

.drain-stat-card .device-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.drain-stat-card .stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.drain-stat-card .stat-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.drain-stat-card .stat-label {
    font-size: 0.8rem;
    opacity: 0.95;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 0;
}

.drain-stat-card .stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.drain-stat-card .stat-value.highlight {
    font-size: 1.4rem;
    color: #ffd700;
}

.drain-stat-card .runtime-estimate {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    text-align: center;
}

.drain-stat-card .runtime-label {
    font-size: 0.8rem;
    margin-bottom: 4px;
    color: rgba(255, 255, 255, 0.9);
}

.drain-stat-card .runtime-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #ffd700;
}

/* ============================================
   Chart Container
   ============================================ */
.chart-container {
    margin-top: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.chart-container canvas {
    max-height: 350px;
}

.chart-description {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 15px;
}

/* ============================================
   Devices Section
   ============================================ */
.devices-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.devices-section h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #333;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

/* Device Card */
.device-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 18px;
    border: 2px solid transparent;
    transition: all 0.2s;
    cursor: pointer;
}

.device-card.active {
    border-color: #10b981;
}

.device-card.inactive {
    border-color: #ef4444;
    opacity: 0.8;
}

.device-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.device-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.device-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-active {
    background: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-inactive {
    background: #ef4444;
}

.device-id {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

/* Battery Indicator */
.battery-indicator {
    width: 100%;
    height: 35px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 15px;
}

.battery-level {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1rem;
    transition: width 0.3s ease;
}

/* Device Details */
.device-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-label {
    font-size: 0.85rem;
    color: #666;
}

.detail-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
}

.detail-value.charging {
    color: #f59e0b;
}

/* ============================================
   Sensor Grid (Multi-Sensor Tab)
   ============================================ */
.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.sensor-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.sensor-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.sensor-icon {
    font-size: 1.8rem;
    margin-right: 10px;
}

.sensor-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.sensor-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: #2563eb;
    margin: 8px 0;
}

.sensor-value.location-value {
    font-size: 1.3rem;
}

.sensor-meta {
    color: #666;
    font-size: 0.9rem;
    margin-top: 8px;
}

/* Sensor Breakdown */
.sensor-breakdown-grid {
    margin-top: 20px;
}

.device-sensor-section {
    margin-bottom: 25px;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.device-sensor-title {
    font-size: 1rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.sensor-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.sensor-stat-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.sensor-stat-card:hover {
    transform: translateY(-2px);
}

.sensor-stat-card.high-activity {
    border-color: #ef4444;
    background: #fef2f2;
}

.sensor-stat-card.medium-activity {
    border-color: #f59e0b;
    background: #fffbeb;
}

.sensor-stat-card.low-activity {
    border-color: #10b981;
    background: #ecfdf5;
}

.sensor-name {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 6px;
}

.sensor-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.sensor-rate {
    font-size: 0.8rem;
    color: #666;
    margin-top: 4px;
}

.sensor-impact {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 6px;
    padding: 3px 6px;
    border-radius: 4px;
    display: inline-block;
}

.sensor-impact.high {
    background: #ef4444;
    color: white;
}

.sensor-impact.medium {
    background: #f59e0b;
    color: white;
}

.sensor-impact.low {
    background: #10b981;
    color: white;
}

/* ============================================
   Map (Sensors Tab)
   ============================================ */
#map {
    height: 350px;
    width: 100%;
    border-radius: 8px;
}

/* ============================================
   Motion Events
   ============================================ */
.event-list {
    list-style: none;
    padding: 0;
}

.event-item {
    padding: 10px;
    margin: 5px 0;
    background: #f3f4f6;
    border-radius: 6px;
    border-left: 4px solid #ef4444;
}

.event-fall {
    border-left-color: #ef4444;
}

.event-sudden {
    border-left-color: #f59e0b;
}

.event-inactive {
    border-left-color: #6b7280;
}

/* ============================================
   Insights Summary (Analytics Tab)
   ============================================ */
.insights-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.insight-card {
    background: white;
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-left: 5px solid #667eea;
    transition: transform 0.2s;
}

.insight-card:hover {
    transform: translateY(-3px);
}

.insight-card.critical {
    border-left-color: #ef4444;
}

.insight-card.warning {
    border-left-color: #f59e0b;
}

.insight-card.info {
    border-left-color: #3b82f6;
}

.insight-card.success {
    border-left-color: #10b981;
}

.insight-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.insight-content {
    flex: 1;
}

.insight-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.insight-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.insight-detail {
    font-size: 0.85rem;
    color: #888;
}

/* ============================================
   Metrics Grid (Analytics Tab)
   ============================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.metric-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border-radius: 10px;
    padding: 18px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
}

.metric-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.metric-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.metric-icon {
    font-size: 1.3rem;
}

.metric-title {
    font-size: 0.85rem;
    color: #666;
    font-weight: 600;
}

.metric-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.metric-status,
.metric-comparison,
.metric-warning,
.metric-detail {
    font-size: 0.8rem;
    color: #888;
}

.metric-status.good {
    color: #10b981;
}

.metric-status.warning {
    color: #f59e0b;
}

.metric-status.critical {
    color: #ef4444;
}

.metric-warning {
    color: #ef4444;
    font-weight: 600;
}

.metric-comparison.better {
    color: #10b981;
}

.metric-comparison.worse {
    color: #ef4444;
}

/* ============================================
   Sensor Impact Grid (Analytics Tab)
   ============================================ */
.sensor-impact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 25px;
}

.sensor-impact-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    border: 2px solid #e5e7eb;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.sensor-impact-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.sensor-impact-card.high-impact::before {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.sensor-impact-card.medium-impact::before {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.sensor-impact-card.low-impact::before {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.sensor-impact-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.sensor-impact-name {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.sensor-impact-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.sensor-impact-percent {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.sensor-impact-percent.high {
    color: #ef4444;
}

.sensor-impact-percent.medium {
    color: #f59e0b;
}

.sensor-impact-percent.low {
    color: #10b981;
}

.sensor-impact-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.sensor-impact-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.sensor-impact-fill.high {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.sensor-impact-fill.medium {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.sensor-impact-fill.low {
    background: linear-gradient(90deg, #10b981, #34d399);
}

/* ============================================
   Health Metrics Grid (Analytics Tab)
   ============================================ */
.health-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.health-card {
    background: white;
    border-radius: 14px;
    padding: 20px;
    display: flex;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
}

.health-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.health-content {
    flex: 1;
}

.health-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.health-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
}

.health-range,
.health-goal,
.health-detail {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 6px;
}

.health-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 15px;
    font-size: 0.75rem;
    font-weight: 600;
}

.health-status.normal {
    background: #ecfdf5;
    color: #10b981;
}

.health-status.elevated {
    background: #fffbeb;
    color: #f59e0b;
}

.health-status.concerning {
    background: #fef2f2;
    color: #ef4444;
}

/* Progress Bar */
.health-progress {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

/* ============================================
   Recommendations (Analytics Tab)
   ============================================ */
.recommendations-section {
    background: linear-gradient(135deg, #f0f4ff 0%, #fff 100%);
}

.recommendations-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recommendation-card {
    background: white;
    border-radius: 10px;
    padding: 15px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.recommendation-card.priority-high {
    border-left-color: #ef4444;
}

.recommendation-card.priority-medium {
    border-left-color: #f59e0b;
}

.recommendation-card.priority-low {
    border-left-color: #10b981;
}

.recommendation-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.recommendation-content {
    flex: 1;
}

.recommendation-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.recommendation-description {
    font-size: 0.85rem;
    color: #666;
    line-height: 1.4;
}

.recommendation-priority {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.recommendation-priority.high {
    background: #fef2f2;
    color: #ef4444;
}

.recommendation-priority.medium {
    background: #fffbeb;
    color: #f59e0b;
}

.recommendation-priority.low {
    background: #ecfdf5;
    color: #10b981;
}

/* ============================================
   MQTT Debug Tab
   ============================================ */
.mqtt-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.status-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.status-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.status-icon.connected,
.status-icon.supabase-status.connected {
    color: #10b981;
}

.status-icon.disconnected,
.status-icon.supabase-status.disconnected,
.status-icon.mqtt-status.error {
    color: #ef4444;
}

.status-icon.warning,
.status-icon.mqtt-status.warning {
    color: #f59e0b;
}

.status-label {
    font-size: 0.85rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.status-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
}

/* Topic Stats */
.topic-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.topic-stat-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.topic-stat-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.topic-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.topic-name {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.topic-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.topic-rate {
    font-size: 0.75rem;
    color: #888;
    margin-top: 4px;
}

/* Message Log */
.message-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    align-items: center;
}

.message-filters select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid #e5e7eb;
    font-size: 0.9rem;
}

.message-log {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f8f9fa;
}

.message-entry {
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    cursor: pointer;
    transition: background 0.2s;
}

.message-entry:hover {
    background: #e5e7eb;
}

.message-entry:last-child {
    border-bottom: none;
}

.message-header {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.message-table {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.message-device {
    font-weight: 600;
    color: #333;
    font-size: 0.85rem;
}

.message-time {
    color: #888;
    font-size: 0.75rem;
    margin-left: auto;
}

.message-preview {
    font-size: 0.85rem;
    color: #666;
    font-family: monospace;
}

/* ============================================
   Quick Actions Footer
   ============================================ */
.quick-actions-footer {
    background: white;
    border-radius: 12px;
    padding: 15px 20px;
    margin-top: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.quick-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-action {
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.connection-indicators {
    display: flex;
    gap: 15px;
}

.indicator {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 5px;
}

.indicator span {
    font-weight: 600;
    color: #333;
}

.indicator.connected span {
    color: #10b981;
}

.indicator.disconnected span {
    color: #ef4444;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 14px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
}

.modal-close:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    max-height: 60vh;
}

.modal-description {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.85rem;
}

/* Device List in Modal */
.device-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.device-item-icon {
    font-size: 1.3rem;
}

.device-item-info {
    flex: 1;
}

.device-item-id {
    font-size: 0.7rem;
    color: #888;
    font-family: monospace;
}

.device-item-name {
    margin-top: 4px;
}

.device-item-input {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}

.device-item-input:focus {
    outline: none;
    border-color: #667eea;
}

.device-item-input::placeholder {
    color: #aaa;
}

/* Data Inspector */
#inspectorContent {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ============================================
   Loading and Error States
   ============================================ */
.loading {
    text-align: center;
    padding: 30px;
    color: #666;
    font-size: 1rem;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.error {
    background: #fee;
    border: 2px solid #fcc;
    border-radius: 8px;
    padding: 15px;
    color: #c00;
    margin-bottom: 15px;
}

.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 1rem;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .devices-grid {
        grid-template-columns: 1fr;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .device-selector-wrapper {
        width: 100%;
    }

    .btn-primary,
    .btn-secondary {
        width: 100%;
    }

    .insights-summary {
        grid-template-columns: 1fr;
    }

    .health-card {
        flex-direction: column;
        text-align: center;
    }

    .recommendation-card {
        flex-direction: column;
    }

    .quick-actions-footer {
        flex-direction: column;
        text-align: center;
    }

    .quick-actions {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .stat-value {
        font-size: 1.6rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .tab-nav {
        flex-direction: column;
    }

    .tab-nav-link {
        text-align: center;
    }

    .sensor-impact-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .metrics-grid {
        grid-template-columns: 1fr;
    }
}
