/**
 * Copyright (c) 2024, 2025, 2026 Pavel Brychta
 * https://www.xpablo.cz
 * Licensed under the MIT License. See LICENSE file for details.
 */

/**
 * Bootstrap 5 Overrides and Custom Theme
 *
 * This file contains Bootstrap variable overrides and custom classes
 * that extend Bootstrap's functionality for PapirLive application.
 */

/* ====================
   CSS Custom Properties (Variables)
   ==================== */

:root {
    /* Primary Color Theme (Bootstrap Blue) */
    --bs-primary: #0d6efd;
    --bs-primary-rgb: 13, 110, 253;

    /* Status Colors */
    --bs-success: #198754;
    --bs-danger: #dc3545;
    --bs-warning: #ffc107;
    --bs-info: #0dcaf0;

    /* Admin Accent */
    --admin-accent: #fd7e14;

    /* Neutral Colors */
    --bs-body-bg: #f8f9fa;
    --bs-body-color: #212529;
    --bs-border-color: #dee2e6;

    /* Custom Status Badge Colors */
    --status-online-bg: #d4edda;
    --status-online-color: #155724;
    --status-recent-bg: #fff3cd;
    --status-recent-color: #856404;
    --status-offline-bg: #f8d7da;
    --status-offline-color: #721c24;
    --status-inactive-bg: #e2e3e5;
    --status-inactive-color: #383d41;
    --status-unknown-bg: #d1ecf1;
    --status-unknown-color: #0c5460;

    /* Device Metrics Colors */
    --wifi-excellent: #198754;
    --wifi-good: #28a745;
    --wifi-fair: #ffc107;
    --wifi-poor: #dc3545;
    --battery-good: #198754;
    --battery-medium: #28a745;
    --battery-low: #ffc107;
    --battery-critical: #dc3545;
}

/* ====================
   Toast Notification Overrides
   ==================== */

/* Custom toast container positioning - preserve existing behavior */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1055; /* Above Bootstrap modals (1050) */
}

/* Mobile toast positioning - bottom center on small screens */
@media (max-width: 768px) {
    .toast-container {
        top: auto;
        bottom: 1rem;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: 90vw;
    }
}

/* ====================
   Status Badge Custom Styles
   ==================== */

/* Custom status badges used by displays.js and admin.js */
.status-badge {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.75em;
    font-weight: 700;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: 0.375rem;
}

.status-badge.online {
    background-color: var(--status-online-bg);
    color: var(--status-online-color);
}

.status-badge.recent {
    background-color: var(--status-recent-bg);
    color: var(--status-recent-color);
}

.status-badge.offline {
    background-color: var(--status-offline-bg);
    color: var(--status-offline-color);
}

.status-badge.inactive {
    background-color: var(--status-inactive-bg);
    color: var(--status-inactive-color);
}

.status-badge.unknown {
    background-color: var(--status-unknown-bg);
    color: var(--status-unknown-color);
}

/* ====================
   Device Metrics Custom Styles
   ==================== */

/* Device metrics container - two-column layout */
.device-metrics {
    display: flex;
    flex-direction: row;
    gap: 12px;
}

/* Each metrics column */
.device-metrics .metrics-column {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Metric item layout with proper spacing */
/* Note: Using .device-metrics prefix for specificity (overrides components.css) */
.device-metrics .metric-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    line-height: 1.2;
}

.device-metrics .metric-icon {
    font-size: 0.8rem;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}

.device-metrics .metric-value {
    font-weight: 500;
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.7rem;
    white-space: nowrap;
}

/* WiFi signal strength colors */
.device-metrics .metric-value.wifi-excellent {
    background-color: #d4edda;
    color: #155724;
}

.device-metrics .metric-value.wifi-good {
    background-color: #d4edda;
    color: #155724;
}

.device-metrics .metric-value.wifi-fair {
    background-color: #fff3cd;
    color: #856404;
}

.device-metrics .metric-value.wifi-poor {
    background-color: #f8d7da;
    color: #721c24;
}

.device-metrics .metric-value.wifi-very-poor {
    background-color: #f8d7da;
    color: #721c24;
    font-weight: 600;
}

/* Battery voltage colors */
.device-metrics .metric-value.battery-good {
    background-color: #d4edda;
    color: #155724;
}

.device-metrics .metric-value.battery-medium {
    background-color: #fff3cd;
    color: #856404;
}

.device-metrics .metric-value.battery-low {
    background-color: #f8d7da;
    color: #721c24;
}

.device-metrics .metric-value.battery-critical {
    background-color: #f8d7da;
    color: #721c24;
    font-weight: 600;
    animation: battery-blink 1.5s infinite;
}

@keyframes battery-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* Last seen info styling */
.last-seen-info {
    font-size: 0.75em;
    color: #6c757d;
    font-style: italic;
}

/* ====================
   Bootstrap Component Overrides
   ==================== */

/* Table cell vertical alignment */
.table td {
    vertical-align: middle;
}

/* Expand/collapse toggle icon rotation */
.expand-icon {
    display: inline-block;
    transition: transform 0.2s ease;
}

.expand-icon.expanded {
    transform: rotate(90deg);
}

/* Admin navbar with custom accent color */
.navbar.bg-admin {
    background: linear-gradient(135deg, var(--admin-accent) 0%, #dc7100 100%) !important;
}

/* Custom gradient background for headers */
.bg-gradient-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%) !important;
}

/* Card shadows */
.card {
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Table responsive improvements */
.table-responsive {
    border-radius: 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Form focus states - match primary color */
.form-control:focus,
.form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* ====================
   Dashboard Preview Overlay
   ==================== */

/* Preview container hover effect */
.preview-container:hover .preview-overlay {
    opacity: 1 !important;
}

/* ====================
   Print Styles
   ==================== */

@media print {
    .toast-container,
    .modal,
    .navbar,
    .btn {
        display: none !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }
}
