/**
 * Path: assets/style-led.css
 * Version: 3.2.0
 * Date: 2025-11-28
 * Time: 14:30:00 +07:00
 * Description: LED Display Specific Styles
 * Changes: Added responsive font scaling with --responsive-scale CSS variable
 */

/* ============================================================================
   CSS VARIABLES (Dynamic Theme Support)
   ============================================================================ */
:root {
    /* LED Layout */
    --led-padding-h: 5%;
    --led-padding-v: 3%;

    /* Header */
    --header-bg: linear-gradient(135deg, #1e40af, #3b82f6);
    --header-text: #ffffff;
    --header-font-size: 2rem;

    /* Background */
    --bg-color: #f8fafc;

    /* Chart */
    --chart-bg: #ffffff;
    --chart-border: #e2e8f0;
    --chart-radius: 1rem;
    --chart-grid: #f1f5f9;

    /* Values */
    --value-text-color: #1e293b;
    --value-label-color: #64748b;
    --value-sublabel-color: #94a3b8;

    /* Footer */
    --footer-bg: #1e293b;
    --footer-text: #e2e8f0;

    /* Operation Mode Lights */
    --mode-light-color: #10b981;
    --mode-light-glow: rgba(52, 211, 153, 0.6);
    --mode-label-color: #1e293b;

    /* Responsive Font Scale (default: 1 = 100%) */
    --responsive-scale: 1;
}

/* ============================================================================
   RESPONSIVE PADDING (Adjust based on screen size)
   ============================================================================ */
@media (min-width: 1920px) {
    :root {
        --led-padding-h: 5%;
        --led-padding-v: 3%;
    }
}

@media (min-width: 3840px) {
    :root {
        --led-padding-h: 8%;
        --led-padding-v: 5%;
    }
}

@media (min-width: 7680px) {
    :root {
        --led-padding-h: 10%;
        --led-padding-v: 6%;
    }
}

/* ============================================================================
   BASE LAYOUT
   ============================================================================ */
.led-display-body {
    margin: 0;
    padding: 0;
    font-family: 'Sarabun', sans-serif;
    overflow: hidden;
    background: var(--bg-color);
}

.led-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: var(--led-padding-v) var(--led-padding-h);
    box-sizing: border-box;
}

/* Fullscreen Mode - No Padding */
.led-container.fullscreen-mode {
    padding: 0;
}

.led-container.fullscreen-mode .led-header {
    border-radius: 0;
}

.led-container.fullscreen-mode .chart-container {
    border-radius: 0;
}

.led-container.fullscreen-mode .led-footer {
    border-radius: 0;
    margin-top: 0;
}

/* ============================================================================
   HEADER SECTION
   ============================================================================ */
.led-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--header-bg);
    color: var(--header-text);
    padding: 1.5rem 2rem;
    border-radius: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.header-left,
.header-right {
    flex: 0 0 auto;
    min-width: 120px;
}

.header-center {
    flex: 1;
    text-align: center;
    padding: 0 2rem;
}

.header-logo {
    height: 80px;
    width: auto;
    object-fit: contain;
}

.header-title {
    font-size: var(--header-font-size);
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    margin: 0.25rem 0 0 0;
    font-weight: 400;
}

.datetime-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.datetime-date {
    font-size: 0.875rem;
    font-weight: 600;
    opacity: 0.9;
}

.datetime-time {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

/* ============================================================================
   OPERATION MODES SECTION
   ============================================================================ */
.operation-modes-container {
    margin: 1.5rem 0;
    flex-shrink: 0;
}

.operation-modes {
    display: flex;
    gap: 2rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.mode-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mode-light {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e5e7eb;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

.mode-light.active {
    background: linear-gradient(135deg, #34d399, var(--mode-light-color));
    box-shadow:
        0 0 20px var(--mode-light-glow),
        0 0 40px rgba(52, 211, 153, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        0 0 0 3px rgba(52, 211, 153, 0.3);
    animation: mode-pulse-glow 2s ease-in-out infinite;
}

.mode-light.active::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--mode-light-glow) 0%, transparent 70%);
    animation: mode-pulse-ring 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes mode-pulse-glow {
    0%, 100% {
        box-shadow:
            0 0 20px var(--mode-light-glow),
            0 0 40px rgba(52, 211, 153, 0.4),
            inset 0 2px 4px rgba(255, 255, 255, 0.3),
            0 0 0 3px rgba(52, 211, 153, 0.3);
    }
    50% {
        box-shadow:
            0 0 30px rgba(52, 211, 153, 0.8),
            0 0 60px rgba(52, 211, 153, 0.5),
            inset 0 2px 4px rgba(255, 255, 255, 0.4),
            0 0 0 4px rgba(52, 211, 153, 0.4);
    }
}

@keyframes mode-pulse-ring {
    0%, 100% {
        transform: scale(1);
        opacity: 0.4;
    }
    50% {
        transform: scale(1.3);
        opacity: 0;
    }
}

.mode-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--mode-label-color);
    white-space: nowrap;
}

/* ============================================================================
   MAIN CONTENT SECTION
   ============================================================================ */
.led-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    position: relative;
    /* Background image support - set via JavaScript from branding settings */
    background-color: transparent;
}

.content-view {
    display: none;
    width: 100%;
    height: 100%;
    flex-direction: column;
}

.content-view.active {
    display: flex;
}

/* ============================================================================
   CHART CONTAINER
   ============================================================================ */
.chart-container {
    flex: 1;
    background: var(--chart-bg);
    border-radius: var(--chart-radius);
    padding: 2rem; /* Chart.js layout.padding.top handles range text space */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--chart-border);
    min-height: 0;
    position: relative;
}

.chart-container canvas {
    max-height: 100%;
}

/* ============================================================================
   VALUES DISPLAY (Below Chart)
   ============================================================================ */
.values-display {
    display: flex;
    justify-content: space-between; /* Align items to match chart bars */
    align-items: flex-start;
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    /* Horizontal padding will be set dynamically by JavaScript to match chart area */
    gap: 0.5rem; /* Small gap for spacing between items */
    flex-wrap: nowrap; /* Prevent wrapping to maintain alignment */
    flex-shrink: 0;
}

.value-item {
    text-align: center;
    flex: 1; /* Equal width for each item to match chart */
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.value-param-name {
    font-size: 1.4rem;
    color: var(--value-label-color);
    font-weight: 600;
    line-height: 1.3;
    min-height: 2.4rem; /* Fixed height to prevent layout shift */
    display: flex;
    align-items: center;
    justify-content: center;
}

.value-datasources {
    display: flex;
    gap: 1.25rem;
    justify-content: center;
    flex-wrap: wrap;
}

.value-datasource {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.value-datasource-label {
    font-size: 1.1rem;
    color: var(--value-sublabel-color);
    font-weight: 500;
    line-height: 1.2;
    min-height: 1.25rem; /* Prevent layout shift */
}

.value-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--value-text-color);
    line-height: 1;
}

.value-unit {
    font-size: 1.1rem;
    color: var(--value-label-color);
    margin-left: 0.25rem;
    font-weight: 400;
}

/* ============================================================================
   ROTATION MEDIA (Video, Image, YouTube, IPTV)
   ============================================================================ */
.rotation-media {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 1rem;
    background: #000000;
}

.iptv-player {
    background: #000000;
}

/* ============================================================================
   FOOTER SECTION
   ============================================================================ */
.led-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--footer-bg);
    color: var(--footer-text);
    padding: 1rem 2rem;
    border-radius: 1rem;
    margin-top: 1.5rem;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.footer-left,
.footer-center,
.footer-right {
    flex: 1;
}

.footer-left {
    text-align: left;
}

.footer-center {
    text-align: center;
    font-weight: 600;
}

.footer-right {
    text-align: right;
}

/* ============================================================================
   LOADING STATE
   ============================================================================ */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* Large screens (4K+) */
@media (min-width: 2560px) {
    :root {
        --responsive-scale: 1.25;
    }
}

/* Standard HD (1920px) */
@media (max-width: 1920px) {
    :root {
        --responsive-scale: 1;
    }
}

/* Medium screens (1280-1920px) */
@media (max-width: 1280px) {
    :root {
        --responsive-scale: 0.85;
    }

    .header-title {
        font-size: 1.5rem;
    }

    .datetime-time {
        font-size: 1.25rem;
    }

    /* Value cards - scale down when inline styles not applied */
    .value-param-name {
        font-size: 1.2rem;
    }

    .value-number {
        font-size: 1.4rem;
    }

    .value-unit {
        font-size: 0.95rem;
    }

    .value-datasource-label {
        font-size: 0.9rem;
    }
}

/* Small screens (1024px) */
@media (max-width: 1024px) {
    :root {
        --responsive-scale: 0.75;
    }

    .value-param-name {
        font-size: 1rem;
    }

    .value-number {
        font-size: 1.2rem;
    }

    .value-unit {
        font-size: 0.85rem;
    }

    .value-datasource-label {
        font-size: 0.8rem;
    }
}

/* Tablet and smaller (768px) */
@media (max-width: 768px) {
    :root {
        --responsive-scale: 0.65;
    }

    .led-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    .header-left,
    .header-right {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    .header-center {
        padding: 0;
    }

    .datetime-display {
        align-items: center;
    }

    .operation-modes {
        gap: 1rem;
    }

    .values-display {
        gap: 0.5rem;
        padding: 0.75rem;
    }

    .value-item {
        gap: 0.5rem;
    }

    .value-param-name {
        font-size: 0.9rem;
        min-height: 1.8rem;
    }

    .value-number {
        font-size: 1rem;
    }

    .value-unit {
        font-size: 0.75rem;
    }

    .value-datasource-label {
        font-size: 0.7rem;
    }

    .led-footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .footer-left,
    .footer-center,
    .footer-right {
        text-align: center;
    }
}

/* Very small screens (480px) */
@media (max-width: 480px) {
    :root {
        --responsive-scale: 0.5;
    }

    .value-param-name {
        font-size: 0.75rem;
        min-height: 1.5rem;
    }

    .value-number {
        font-size: 0.85rem;
    }

    .value-unit {
        font-size: 0.65rem;
    }

    .value-datasource-label {
        font-size: 0.6rem;
    }
}

/* ============================================================================
   FULLSCREEN ADVERTISEMENT OVERLAY
   ============================================================================ */
.ad-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9990;
    background: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-fullscreen-overlay.hidden {
    display: none;
}

.ad-fullscreen-media {
    max-width: 100%;
    max-height: 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000000;
}

/* Image specific - contain to show full image */
.ad-fullscreen-media.ad-image {
    object-fit: contain;
}

/* Video specific - cover to fill screen */
.ad-fullscreen-media.ad-video {
    object-fit: contain;
}

/* YouTube iframe - fill container */
.ad-fullscreen-media.ad-youtube {
    border: none;
}

/* IPTV video - same as regular video */
.ad-fullscreen-media.ad-iptv {
    object-fit: contain;
}

/* Webpage iframe - white background for content visibility */
.ad-fullscreen-media.ad-webpage {
    border: none;
    background: #ffffff;
}

/* ============================================================================
   MARQUEE (Must be above fullscreen overlay)
   ============================================================================ */
#marquee-container {
    position: fixed !important;
    z-index: 9995 !important;
    pointer-events: none;
}

/* Ensure marquee is visible even during fullscreen advertisement */
/* Note: DO NOT use opacity: 1 !important - it overrides user-configured opacity */
#marquee-container.marquee-visible {
    display: flex !important;
    visibility: visible !important;
}
