/* Smart Farm Dashboard - Professional Fixed Position CSS - FINAL VERSION */

/* ===========================
   1. CSS Variables & Root
   =========================== */
:root {
    /* Color Palette */
    --primary-green: #10b981;
    --secondary-green: #059669;
    --accent-red: #ef4444;
    --accent-blue: #3b82f6;
    --accent-orange: #f59e0b;
    --bg-white: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.25);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --border-color: rgba(255, 255, 255, 0.3);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-success: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    --gradient-warning: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-info: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    
    /* Layout Constants */
    --base-width: 1400px;
    --base-height: 900px;
    --aspect-ratio: 1.5556; /* 1400/900 */
}

/* ===========================
   2. Container & Layout - PROFESSIONAL SCALING
   =========================== */
.smartfarm-container {
    width: 100%;
    max-width: 100vw;
    height: 100vh;
    margin: 0 auto;
    position: relative;
    padding: 1.5vw;
    background: linear-gradient(to bottom, #f0f9ff, #e0f2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Responsive Wrapper - No complex scaling needed! */
.scaling-wrapper {
    position: relative;
    width: 100%;
    max-width: min(90vw, 90vh * var(--aspect-ratio));
    height: calc(100vw / var(--aspect-ratio));
    max-height: 90vh;
    transform-origin: center center;
    transition: all 0.3s ease;
}

/* Background Image Container - Fully Responsive */
.background-image {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: calc(100% / var(--aspect-ratio)); /* Maintain aspect ratio */
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 16px;
    overflow: visible;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* Background overlay */
.background-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 40%, rgba(0, 0, 0, 0.02) 100%);
    pointer-events: none;
}

/* ===========================
   3. Time Display - Fixed Position (UPDATED)
   =========================== */
.time-display {
    position: absolute;
    top: 3%; /* ปรับให้อยู่ระดับเดียวกับ PM2.5 และ CO2 */
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 12px 30px;
    border-radius: 20px;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 
        0 8px 32px rgba(31, 38, 135, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
    border: 1px solid var(--border-color);
    text-align: center;
    z-index: 100;
    transition: all 0.3s ease;
    animation: slideDown 0.6s ease-out;
    font-size: 1rem;
    white-space: nowrap;
}

/* Responsive adjustments for time display */
@media screen and (max-width: 1366px) {
    /* สำหรับจอ 14 นิ้ว */
    .time-display {
        top: 3%; /* คงระดับเดียวกันทุกขนาดจอ */
        font-size: 0.9rem;
        padding: 10px 25px;
    }
    
    #current-clock {
        font-size: 1rem !important;
    }
}

@media screen and (min-width: 1920px) {
    /* สำหรับจอ 24 นิ้ว */
    .time-display {
        top: 3%; /* คงระดับเดียวกันทุกขนาดจอ */
        padding: 14px 35px;
    }
    
    #current-clock {
        font-size: 1.1rem !important;
    }
}

/* สำหรับจอที่มีความสูงน้อย */
@media screen and (max-height: 768px) {
    .time-display {
        top: 3%; /* คงระดับเดียวกันทุกขนาดจอ */
    }
}

.time-display:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 
        0 12px 40px rgba(31, 38, 135, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* จัดแนวให้ตรงกับ sensor boxes */
.time-display {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80px; /* ให้มีความสูงใกล้เคียงกับ sensor boxes */
}

#last-update-label {
    font-size: 0.9rem;
    color: var(--primary-green);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    opacity: 0.9;
}

#current-date {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

#current-clock {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.5px;
}

/* ===========================
   4. Sensor Styles - FIXED SIZING
   =========================== */
.sensor-value {
    position: absolute;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    padding: 10px 14px;
    border-radius: 16px;
    box-shadow: 
        0 8px 32px rgba(31, 38, 135, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    border: 1px solid var(--border-color);
    font-size: 0.875rem;
    line-height: 1.4;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 120px;
    max-width: 200px;
    animation: fadeInScale 0.5s ease-out;
    animation-fill-mode: both;
    transform-origin: center center;
}

/* Stagger animation for sensors */
.sensor-value:nth-child(1) { animation-delay: 0.1s; }
.sensor-value:nth-child(2) { animation-delay: 0.15s; }
.sensor-value:nth-child(3) { animation-delay: 0.2s; }
.sensor-value:nth-child(4) { animation-delay: 0.25s; }
.sensor-value:nth-child(5) { animation-delay: 0.3s; }
.sensor-value:nth-child(6) { animation-delay: 0.35s; }
.sensor-value:nth-child(7) { animation-delay: 0.4s; }
.sensor-value:nth-child(8) { animation-delay: 0.45s; }
.sensor-value:nth-child(9) { animation-delay: 0.5s; }
.sensor-value:nth-child(10) { animation-delay: 0.55s; }
.sensor-value:nth-child(11) { animation-delay: 0.6s; }
.sensor-value:nth-child(12) { animation-delay: 0.65s; }
.sensor-value:nth-child(13) { animation-delay: 0.7s; }
.sensor-value:nth-child(14) { animation-delay: 0.75s; }
.sensor-value:nth-child(15) { animation-delay: 0.8s; }
.sensor-value:nth-child(16) { animation-delay: 0.85s; }

/* Hover effects */
.sensor-value:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 
        0 20px 40px rgba(31, 38, 135, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.35);
    z-index: 50;
}

.sensor-value h2 {
    font-size: 0.9rem !important;
    margin: 0 0 6px 0;
    color: var(--secondary-green);
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding-bottom: 6px;
    border-bottom: 2px solid rgba(16, 185, 129, 0.3);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sensor-value h2 i {
    font-size: 0.9em;
    opacity: 0.8;
    transition: all 0.3s ease;
}

.sensor-value:hover h2 i {
    opacity: 1;
    transform: scale(1.1);
}

.sensor-value p {
    margin: 3px 0;
    font-size: 0.85rem !important;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sensor-value strong {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.8rem !important;
}

.sensor-value .value {
    font-weight: 700;
    font-size: 1rem !important;
    background: linear-gradient(135deg, var(--primary-green), var(--secondary-green));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* Color coding for different sensor types */
.sensor-value[data-type="moisture"] .value {
    background: var(--gradient-info);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* Status indicators */
.sensor-value::before {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-green);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    animation: pulse-dot 2s infinite;
}

/* NPK specific styling with vertical layout */
.npk-values {
    display: flex;
    flex-direction: column !important;
    gap: 5px;
    margin-top: 6px;
    font-size: 0; /* Hide text nodes (pipes) */
}

/* Support both <p> and <span> elements in NPK values */
.npk-values p,
.npk-values span {
    background: rgba(16, 185, 129, 0.15);
    padding: 5px 10px;
    border-radius: 6px;
    margin: 0;
    font-size: 0.82rem !important;
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-left: 3px solid rgba(16, 185, 129, 0.5);
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.npk-values p:hover,
.npk-values span:hover {
    background: rgba(16, 185, 129, 0.25);
    border-left-color: rgba(16, 185, 129, 0.8);
    transform: translateX(2px);
}

.npk-values p strong,
.npk-values span strong {
    color: var(--secondary-green);
    font-weight: 700;
    min-width: 20px;
}

.npk-values p .value,
.npk-values span .value {
    font-weight: 700;
    margin-left: auto;
}

/* Ensure all NPK sensors have consistent width */
#sensor-2, #sensor-7, #sensor-10 {
    min-width: 150px;
}

/* Farm 2 has NPK sensors that need same width */
.farm2 #sensor-2,
.farm2 #sensor-7,
.farm2 #sensor-10,
.farm1 #sensor-2,
.farm1 #sensor-10,
.farm1 #sensor-7 {
    min-width: 150px;
}

/* ===========================
   5. Fixed Sensor Positions - FINAL POSITIONS
   =========================== */

/* Farm 1 Sensor Positions - Responsive Percentage-based (Restructured like Farm 2) */
/* Base calculations: 1400px width x 900px height */
/* 
   RESTRUCTURED TO MATCH FARM 2 FORMAT:
   - Sensor count reduced from 16 to 12
   - Moisture sensors combined (หัว+ท้าย in same sensor)
   - Same structure as Farm 2 for consistency
   - Positions kept the same as original Farm 1 design
*/
.farm1 #sensor-5 { position: absolute; top: 5.56%; left: 67.86%; } /* PM2.5 - top right (50px / 900px = 5.56%, 950px / 1400px = 67.86%) */
.farm1 #sensor-3 { position: absolute; top: 5.56%; left: 80%; } /* CO2 - top right (50px / 900px = 5.56%, 1120px / 1400px = 80%) */

/* R8 Section - Now combined humidity */
.farm1 #sensor-1 { position: absolute; top: 79%; left: 51%; } /* ความชื้น-R8 หัว+ท้าย (759px / 900px = 84.33%, 660px / 1400px = 47.14%) */
.farm1 #sensor-2 { position: absolute; top: 69%; left: 36.07%; } /* ค่า NPK-R8 (670px / 900px = 74.44%, 505px / 1400px = 36.07%) */
.farm1 #sensor-4 { position: absolute; top: 60%; left: 23.5%; } /* PPFD-R8 (630px / 900px = 70%, 350px / 1400px = 25%) */
.farm1 #sensor-9 { position: absolute; top: 49%; left: 7%; } /* SHT-8 (513px / 900px = 57%, 105px / 1400px = 7.5%) */

/* R16 Section - Now combined humidity */
.farm1 #sensor-12 { position: absolute; top: 65%; left: 64.29%; } /* ความชื้น-R16 หัว+ท้าย (660px / 900px = 73.33%, 900px / 1400px = 64.29%) */
.farm1 #sensor-10 { position: absolute; top: 9%; left: 18%; } /* ค่า NPK-R16 (160px / 900px = 17.78%, 260px / 1400px = 18.57%) */

/* R24 Section - Now combined humidity */
.farm1 #sensor-6 { position: absolute; top: 45%; left: 81.43%; } /* ความชื้น-R24 หัว+ท้าย (510px / 900px = 56.67%, 1140px / 1400px = 81.43%) */
.farm1 #sensor-7 { position: absolute; top: 61%; left: 81.43%; } /* ค่า NPK-R24 (592px / 900px = 65.78%, 1140px / 1400px = 81.43%) */
.farm1 #sensor-8 { position: absolute; top: 17.78%; left: 48%; } /* SHT-R24 (160px / 900px = 17.78%, 697px / 1400px = 49.79%) */
.farm1 #sensor-11 { position: absolute; top: 17.78%; left: 61%; } /* PPFD-R24 (160px / 900px = 17.78%, 980px / 1400px = 70%) */

/* Farm 2 Sensor Positions - Responsive Percentage-based */
/* Base calculations: 1400px width x 900px height */
.farm2 #sensor-3 { position: absolute; top: 5.56%; left: 67.86%; } /* CO2 (50px / 900px = 5.56%, 950px / 1400px = 67.86%) */
.farm2 #sensor-5 { position: absolute; top: 5.56%; left: 80%; } /* PM2.5 (50px / 900px = 5.56%, 1120px / 1400px = 80%) */

.farm2 #sensor-1 { position: absolute; top: 63.67%; left: 26.43%; } /* ความชื้น-R8 (600px / 900px = 66.67%, 370px / 1400px = 26.43%) */
.farm2 #sensor-2 { position: absolute; top: 63.67%; left: 11.7%; } /* ค่า NPK-R8 (600px / 900px = 66.67%, 215px / 1400px = 15.36%) */
.farm2 #sensor-9 { position: absolute; top: 77.44%; left: 50%; } /* SHT-8 (715px / 900px = 79.44%, 700px / 1400px = 50%) */

.farm2 #sensor-10 { position: absolute; top: 62.89%; left: 65.2%; } /* ค่า NPK-R16 (620px / 900px = 68.89%, 900px / 1400px = 64.29%) */
.farm2 #sensor-11 { position: absolute; top: 62.89%; left: 80%; } /* PPFD-R16 (620px / 900px = 68.89%, 1055px / 1400px = 75.36%) */

.farm2 #sensor-6 { position: absolute; top: 23.33%; left: 62.86%; } /* ความชื้น-R24 (210px / 900px = 23.33%, 950px / 1400px = 67.86%) */
.farm2 #sensor-7 { position: absolute; top: 23.33%; left: 77.1%; } /* ค่า NPK-R24 (210px / 900px = 23.33%, 1100px / 1400px = 78.57%) */
.farm2 #sensor-8 { position: absolute; top: 16.5%; left: 32.57%; } /* SHT-R24 (130px / 900px = 14.44%, 470px / 1400px = 33.57%) */
.farm2 #sensor-4 { position: absolute; top: 16.5%; left: 20.07%; } /* PPFD-R24 (130px / 900px = 14.44%, 337px / 1400px = 24.07%) */

/* Special styling for edge sensors */
.farm1 #sensor-6,
.farm1 #sensor-7,
.farm1 #sensor-2,
.farm1 #sensor-10,
.farm1 #sensor-12,
.farm2 #sensor-6,
.farm2 #sensor-7,
.farm2 #sensor-2,
.farm2 #sensor-10 {
    max-width: 150px;
}

/* Ensure consistent styling for both farms */
.farm1 .sensor-value,
.farm2 .sensor-value {
    /* Same base styles for both farms */
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
}

/* Consistent NPK sensor widths for both farms */
.farm1 #sensor-2, .farm1 #sensor-7, .farm1 #sensor-10,
.farm2 #sensor-2, .farm2 #sensor-7, .farm2 #sensor-10 {
    min-width: 150px;
}



/* Consistent time display for both farms */
.farm1 .time-display,
.farm2 .time-display {
    top: 4%;
    left: 50%;
    transform: translateX(-50%);
}

/* Edge sensor indicator */
.sensor-value.edge-sensor {
    border-color: #f59e0b !important;
    background: rgba(245, 158, 11, 0.1) !important;
}

.sensor-value.edge-sensor::after {
    content: '⚠️';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 0.8rem;
    background: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* ===========================
   6. Navigation Controls - Professional Design
   =========================== */
/* Old style - keep for backward compatibility */
/* .smartfarm-container > .mb-3 {
    display: none;
} */

/* New navigation controls */
.navigation-controls {
    position: fixed;
    top: 20px;
    right: 250px;
    z-index: 200;
    display: flex;
    gap: 12px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 252, 0.95));
    padding: 12px 20px;
    border-radius: 15px;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.04);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    animation: slideInFromLeft 0.4s ease-out;
}

/* Button styles enhancement */
.navigation-controls .btn {
    padding: 8px 20px;
    font-weight: 500;
    border-radius: 10px;
    transition: all 0.3s ease;
    border: none;
    font-size: 0.95rem;
}

.navigation-controls .btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

.navigation-controls .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.navigation-controls .btn-outline-secondary {
    background: white;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.navigation-controls .btn-outline-secondary:hover {
    background: #f9fafb;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    color: #4b5563;
}

/* Visual indicator for active page */
/* .navigation-controls::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, #10b981, #059669);
    border-radius: 0 4px 4px 0;
} */

/* Responsive adjustments */
@media (max-width: 1400px) {
    .navigation-controls {
        left: 270px;
    }
}

@media (max-width: 1200px) {
    .navigation-controls {
        top: 70px;
        left: 20px;
        right: 20px;
        position: relative;
        margin-bottom: 20px;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .navigation-controls {
        flex-direction: column;
        width: 100%;
        padding: 10px;
    }
    
    .navigation-controls .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ===========================
   7. Responsive Scaling Logic
   =========================== */
/* For screens smaller than base dimensions */
@media screen and (max-width: 1440px), screen and (max-height: 920px) {
    .scaling-wrapper {
        transform: scale(var(--scale-factor, 1));
    }
}

/* Tablet specific adjustments */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .smartfarm-container {
        padding: 10px;
    }
    
    .sensor-value {
        min-width: 100px;
        padding: 8px 12px;
    }
}

/* Mobile Layout - Different approach */
@media screen and (max-width: 767px) {
    .smartfarm-container {
        height: auto;
        min-height: 100vh;
        padding: 3vw;
        align-items: flex-start;
    }
    
    .scaling-wrapper {
        width: 100%;
        max-width: none;
        height: auto;
    }
    
    .background-image {
        position: relative;
        width: 100%;
        height: auto;
        background-size: cover;
        background-position: center;
        display: flex;
        flex-wrap: wrap;
        align-content: flex-start;
        justify-content: center;
        gap: 8px;
        padding: 15px;
        padding-bottom: 56.25%; /* 16:9 aspect ratio for mobile */
        box-sizing: border-box;
    }
    
    .sensor-value {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        flex: 0 0 calc(50% - 4px);
        max-width: calc(50% - 4px);
        margin: 0;
        font-size: 0.7rem;
        padding: 8px 10px;
        min-width: auto;
    }
    
    /* Full width for NPK sensors on mobile */
    .sensor-value:has(.npk-values) {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .sensor-value h2 {
        font-size: 0.75rem !important;
        margin-bottom: 4px;
    }
    
    .sensor-value p {
        font-size: 0.65rem !important;
        margin: 2px 0;
    }
    
    .npk-values p {
        padding: 3px 6px;
        font-size: 0.6rem !important;
    }
    
    /* Responsive time display */
    .time-display {
        position: relative;
        top: auto;
        left: auto;
        transform: none;
        order: -1;
        flex: 0 0 100%;
        margin-bottom: 10px;
        font-size: 0.8rem;
        padding: 8px 15px;
    }
}

/* ===========================
   8. Dark Mode Support
   =========================== */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-glass: rgba(30, 30, 30, 0.6);
        --text-primary: #f9fafb;
        --text-secondary: #d1d5db;
        --border-color: rgba(255, 255, 255, 0.1);
        --shadow-color: rgba(0, 0, 0, 0.3);
    }
    
    .smartfarm-container {
        background: linear-gradient(to bottom, #0f172a, #1e293b);
    }
    
    .sensor-value {
        background: var(--bg-glass);
        border-color: var(--border-color);
    }
    
    .time-display {
        background: var(--bg-glass);
        border-color: var(--border-color);
    }
}

.dark-mode {
    background: #1a1a1a;
    color: white;
}

.dark-mode .smartfarm-container {
    background: linear-gradient(to bottom, #0f172a, #1e293b);
}

.dark-mode .sensor-value,
.dark-mode .time-display {
    background: rgba(30, 30, 30, 0.8);
    color: white;
}

.dark-mode .sensor-value h2 {
    color: #34d399;
    border-bottom-color: rgba(52, 211, 153, 0.3);
}

.dark-mode .sensor-value strong,
.dark-mode .sensor-value p {
    color: #e5e7eb;
}

/* ===========================
   9. Animations
   =========================== */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse-dot {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.7;
    }
}

/* ===========================
   10. Print Styles
   =========================== */
@media print {
    .scaling-wrapper {
        transform: scale(0.7) !important;
    }
    
    .smartfarm-container > .mb-3,
    .navigation-controls,
    .refresh-btn,
    .dark-mode-toggle,
    .auto-refresh-toggle {
        display: none !important;
    }
}

/* ===========================
   11. Utility Classes
   =========================== */
/* Loading state */
.sensor-loading {
    opacity: 0.6;
    animation: shimmer 1.5s infinite;
}

.sensor-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shimmer-slide 1.5s infinite;
}

@keyframes shimmer {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 0.8;
    }
}

@keyframes shimmer-slide {
    to {
        left: 100%;
    }
}

/* Highlighted state */
.sensor-value.highlighted {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(245, 158, 11, 0.3)) !important;
    border-color: var(--accent-orange) !important;
    box-shadow: 
        0 0 0 4px rgba(245, 158, 11, 0.2),
        0 20px 40px rgba(245, 158, 11, 0.3) !important;
    transform: scale(1.05);
}

/* Mobile sensor grid */
.mobile-sensor-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px;
    justify-content: center;
}

.sensor-category-header {
    width: 100%;
    padding: 10px;
    margin: 10px 0 5px 0;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 8px;
    font-weight: 600;
    color: #10b981;
    text-align: center;
}

/* Enhanced button styles */
.btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2) !important;
    border: none !important;
    transition: all 0.3s ease !important;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(103, 126, 234, 0.4) !important;
}

/* Special styling for NPK-R24 sensor */
#sensor-7 {
    min-width: 150px;
}

/* ===========================
   12. Responsive Utilities & Performance
   =========================== */
/* Responsive text sizing */
.responsive-text {
    font-size: clamp(0.75rem, 2vw, 1rem);
}

.responsive-text-sm {
    font-size: clamp(0.65rem, 1.5vw, 0.85rem);
}

.responsive-text-lg {
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
}

/* Responsive spacing */
.responsive-padding {
    padding: clamp(8px, 2vw, 16px);
}

.responsive-margin {
    margin: clamp(4px, 1vw, 10px);
}

/* Responsive widths */
.responsive-width {
    width: clamp(100px, 15vw, 200px);
}

/* Hide utilities */
@media (max-width: 767px) {
    .hide-mobile {
        display: none;
    }
}

@media (min-width: 768px) {
    .hide-desktop {
        display: none;
    }
}

/* Responsive flex */
.responsive-flex {
    display: flex;
    flex-wrap: wrap;
    gap: clamp(5px, 1vw, 15px);
}

.responsive-flex > * {
    flex: 1 1 clamp(120px, 25%, 200px);
}

/* Performance optimizations */
.sensor-value {
    contain: layout style;
    will-change: auto;
}

.sensor-value:hover {
    will-change: transform, box-shadow;
}

.sensor-value:not(:hover) {
    will-change: auto;
}

/* ===========================
   13. AJAX Update Animations
   =========================== */
.sensor-value .value.updating {
    animation: pulse-update 0.6s ease;
    color: #10b981 !important;
    font-weight: 700;
}

@keyframes pulse-update {
    0% { 
        transform: scale(1); 
        opacity: 1; 
    }
    50% { 
        transform: scale(1.15); 
        opacity: 0.8;
        color: #059669;
    }
    100% { 
        transform: scale(1); 
        opacity: 1; 
    }
}

.sensor-value.value-updated {
    animation: flash-border 0.6s ease;
}

@keyframes flash-border {
    0% { 
        border-color: rgba(16, 185, 129, 0.3);
        box-shadow: 0 8px 32px rgba(31, 38, 135, 0.12);
    }
    50% { 
        border-color: rgba(16, 185, 129, 0.8);
        box-shadow: 0 8px 32px rgba(16, 185, 129, 0.3);
    }
    100% { 
        border-color: rgba(255, 255, 255, 0.3);
        box-shadow: 0 8px 32px rgba(31, 38, 135, 0.12);
    }
}

/* Refresh indicator */
.refresh-indicator {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(50px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Prevent layout shift during updates */
.sensor-value .value {
    display: inline-block;
    min-width: 3ch;
    text-align: right;
}