    /* ==========================================================================
   VARIABLES & BASE SETUP
========================================================================== */
:root {
    --bg-main: #F1EFE9;
    --bg-card: #FFFFFF;
    
    --text-dark: #1F2937; /* gray-800 */
    --text-medium: #4B5563; /* gray-600 */
    --text-light: #9CA3AF; /* gray-400 */
    
    --accent-primary: #A3B18A;
    --accent-primary-hover: #8F9D76;
    --accent-orange: #FB923C; /* orange-400 */
    --accent-green: #34D399; /* emerald-400 */
    
    --bg-offline: #0F172A; /* slate-900 */
    --bg-chat: #F9FAFB; /* gray-50 */
    
    --radius-card: 1.75rem; /* ~28px */
    --radius-pill: 9999px;
    
    --shadow-soft: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    
    --transition: all 0.3s ease;
}

body {
    background-color: var(--bg-main);
    color: var(--text-dark);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding: 1.5rem;
}

/* ==========================================================================
   LAYOUT
========================================================================== */
.dashboard-wrapper {
    max-width: 1440px;
    margin: 0 auto;
}

.sensor-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.main-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .sensor-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .sensor-grid { grid-template-columns: repeat(3, 1fr); }
    .main-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1280px) {
    .sensor-grid { grid-template-columns: repeat(6, 1fr); gap: 1rem; }
    .main-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ==========================================================================
   HEADER
========================================================================== */
.header {
    background: var(--bg-card);
    border-radius: var(--radius-pill);
    padding: 0.75rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-soft);
    margin-bottom: 2rem;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo img {
    height: 48px; /* Adjust if their logo is big */
    width: auto;
}

.icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--bg-chat);
    border: 1px solid #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--accent-primary);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.header-title h1 {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-dark);
    margin: 0;
}

.header-title p {
    font-size: 0.75rem;
    color: var(--text-medium);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 2s infinite;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    transform: scale(1.1);
}

.greeting {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-medium);
    display: none; /* Hide on mobile by default */
}
@media (min-width: 768px) {
    .greeting { display: block; }
}
.greeting span { font-size: 1.125rem; }

.user-profile {
    position: relative;
    cursor: pointer;
}

.avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-text {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent-primary);
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    width: 220px;
    background: white;
    border-radius: 1rem;
    box-shadow: var(--shadow-md);
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: var(--transition);
    z-index: 50;
    border: 1px solid #F3F4F6;
}

.dropdown-menu::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 0;
    width: 100%;
    height: 15px;
    background: transparent;
}

.user-profile:hover .dropdown-menu,
.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.875rem;
}
.dropdown-menu a:hover { background: #F9FAFB; }
.dropdown-menu hr { margin: 0.5rem 0; border: none; border-bottom: 1px solid #E5E7EB; }
.text-danger { color: #EF4444 !important; }


/* ==========================================================================
   CARDS COMMON (Sensors, Rooms, etc)
========================================================================== */
.card, .sensor-card {
    background: var(--bg-card);
    border-radius: var(--radius-card);
    padding: 1.25rem;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover, .sensor-card:hover {
    box-shadow: var(--shadow-md);
}

/* ==========================================================================
   SENSOR TOP CARDS
========================================================================== */
.sensor-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 2;
}

.sensor-value {
    font-size: 2.25rem; /* ~36px */
    font-weight: 700;
    color: var(--text-dark);
    position: relative;
    z-index: 2;
}

.sensor-value .unit {
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text-light);
}

.sensor-status {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-medium);
    margin-top: 1rem;
    position: relative;
    z-index: 2;
}

.sensor-dot {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.dot-orange { background-color: var(--accent-orange); }
.dot-green { background-color: var(--accent-green); }
.dot-gray { background-color: #D1D5DB; }

.bg-icon {
    position: absolute;
    bottom: 1.25rem;
    right: 1.25rem;
    font-size: 2rem;
    z-index: 1;
    opacity: 0.8;
    transition: var(--transition);
}
.sensor-card:hover .bg-icon { transform: scale(1.1); }
.icon-orange { color: var(--accent-orange); } 
.icon-green { color: var(--accent-green); } 
.icon-gray { color: var(--text-light); } 

.card-security {
    border-left: 4px solid var(--accent-green);
}
.security-text {
    display: flex; 
    align-items: center; 
    gap: 0.5rem;
    color: var(--text-dark);
}
.security-text i { color: var(--accent-green); }

/* Quick Control Additions */
.quick-control-card {
    display: flex;
    flex-direction: column;
}
.quick-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 0.5rem;
    position: relative;
    z-index: 2;
}

.qc-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #F9FAFB;
    padding: 0.4rem 0.5rem; /* Reduced padding */
    border-radius: 0.75rem;
    border: 1px solid #F3F4F6;
    overflow: hidden;
}

.mini-switch {
    width: 32px;
    height: 18px;
    flex-shrink: 0;
    margin-left: 4px;
}
.mini-switch .slider:before {
    height: 20px; 
    width: 20px;
    left: 2px; 
    bottom: 2px;
}
.mini-switch input:checked + .slider:before {
    transform: translateX(14px);
}




/* ==========================================================================
   MAIN GRID COLUMNS
========================================================================== */
.column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
}
.space-between { justify-content: space-between; }
.border-bottom { 
    border-bottom: 1px solid #F3F4F6; 
    padding-bottom: 1.5rem; 
}

.card-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-dark);
}
.title-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.75rem;
    background-color: var(--bg-chat);
    border: 1px solid #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: center;
}
.title-icon.icon-gray { color: var(--text-light); }

/* Room Controls */
.carousel-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.carousel-controls button {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #F3F4F6;
    border: none;
    color: var(--text-medium);
    font-size: 0.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.carousel-controls button:hover { background-color: #E5E7EB; }
.dots { display: flex; gap: 4px; }
.dots span {
    width: 6px; height: 6px; border-radius: 50%; background-color: #D1D5DB;
}
.dots span.active { background-color: var(--text-dark); }

#room-stack {
    position: relative;
    overflow: hidden;
}

.room-slide {
    display: none;
    animation: fadeIn 0.3s ease;
}

.room-slide.is-active {
    display: block;
}

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

.room-stats {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.room-stats::-webkit-scrollbar {
    display: none;
}
.stat-pill {
    flex: 1 0 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.5rem;
    border-radius: 0.75rem;
    border: 1px solid #F3F4F6;
    background: rgba(249, 250, 251, 0.5);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-medium);
    white-space: nowrap;
}
.stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.pill-active {
    border-color: #FFEDD5; /* orange-100 */
    background: rgba(255, 237, 213, 0.3);
    color: #F97316; /* orange-500 */
}

.device-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.device-item {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    border: 1px solid #F3F4F6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    color: var(--text-medium);
}
.device-icon {
    width: 32px; height: 32px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
.icon-yellow { background: #FEF3C7; color: #F59E0B; }
.icon-blue { background: #EFF6FF; color: #3B82F6; }
.icon-purple { background: #F3E8FF; color: #A855F7; }
.icon-green { background: #DCFCE7; color: #22C55E; }
.icon-slate { background: #F1F5F9; color: #64748B; }


/* Custom Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #E5E7EB;
    transition: .4s;
    border-radius: 24px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.toggle-switch input:checked + .slider {
    background-color: var(--accent-primary);
}
.toggle-switch input:checked + .slider:before {
    transform: translateX(24px);
}


/* Camera Controller */
.icon-gray-fade { color: var(--text-light); margin-right: 0.5rem; }

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.625rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.badge-offline { background: #F3F4F6; color: var(--text-light); }
.badge .dot { width: 4px; height: 4px; border-radius: 50%; background: currentColor; }

.camera-view {
    background-color: var(--bg-offline);
    border-radius: 1.5rem;
    min-height: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.2);
    margin-bottom: 1rem;
    cursor: pointer;
    overflow: hidden;
}

.cam-icon {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    color: #D1D5DB;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    transition: var(--transition);
}
.camera-view:hover .cam-icon { background: rgba(255,255,255,0.2); }

.cam-status {
    font-size: 0.875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #D1D5DB;
    margin-bottom: 1.5rem;
}

.btn-primary {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius-pill);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; gap: 0.5rem;
    transition: var(--transition);
}
.btn-primary:hover { background: rgba(255,255,255,0.2); }

.cam-label {
    position: absolute;
    bottom: 1rem; left: 1rem;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.1);
    color: #D1D5DB;
    font-family: monospace;
    font-size: 0.625rem;
    padding: 0.35rem 0.5rem;
    border-radius: 0.5rem;
}

.btn-outline {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px dashed #D1D5DB;
    border-radius: 1rem;
    color: var(--text-light);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}
.btn-outline:hover { background: #F9FAFB; }


/* Agent Gemini Chat */
.agent-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.agent-avatar {
    position: relative;
    width: 56px; height: 56px;
    background-color: var(--accent-primary);
    border-radius: 1.25rem;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.5rem;
    box-shadow: 0 4px 14px rgba(163, 177, 138, 0.4);
}
.online-dot {
    position: absolute;
    bottom: -4px; right: -4px;
    width: 16px; height: 16px;
    background-color: var(--accent-green);
    border: 2px solid white;
    border-radius: 50%;
}
.agent-info{
    padding-left: 10px;
}
.agent-info h2 {
    font-size: 1.25rem; font-weight: 700; color: var(--text-dark); margin: 0;
}
.agent-info p {
    font-size: 0.75rem; color: var(--text-light); margin: 0.25rem 0 0 0;
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-message {
    display: flex; gap: 0.75rem;
}
.bot-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--bg-chat);
    border: 1px solid #F3F4F6;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-light);
    font-size: 0.75rem;
    flex-shrink: 0;
}
.message-bubble {
    background: var(--bg-chat);
    border: 1px solid #F3F4F6;
    padding: 1rem;
    border-radius: 1rem;
    border-top-left-radius: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-medium);
    line-height: 1.6;
}

.chat-input-wrapper {
    position: relative;
    margin-top: auto;
}
.chat-input {
    width: 100%;
    background: var(--bg-chat);
    border: 1px solid #E5E7EB;
    border-radius: var(--radius-pill);
    padding: 1rem 3.5rem 1rem 1.25rem;
    font-size: 0.875rem;
    color: var(--text-dark);
    outline: none;
    transition: var(--transition);
}
.chat-input:focus { border-color: var(--accent-primary); }

.btn-send {
    position: absolute;
    right: 0.5rem; top: 0.5rem; bottom: 0.5rem;
    width: calc(100% - 1rem);
    max-width: 40px;
    border-radius: 50%;
    background: var(--accent-primary);
    border: none;
    color: white;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(163, 177, 138, 0.3);
    transition: var(--transition);
}
.btn-send:hover { background-color: var(--accent-primary-hover); }

/* Kitchen Card */
.kitchen-card {
    background-color: #FFF7ED; /* orange-50 expected */
    border: 1px solid #FFEDD5; /* orange-100 expected */
}
.text-orange { color: #EA580C; }
.icon-orange-light { background: #FFEDD5; color: #EA580C; border: none; }
.badge-warning { background: #FFEDD5; color: #EA580C; padding: 0.35rem 0.75rem; animation: pulse 2s infinite; }
.badge-warning .dot { background-color: #EA580C; }

.kitchen-body {
    display: flex;
    gap: 1rem;
}

.gas-block {
    background: white;
    padding: 1rem;
    border-radius: 1rem;
    border: 1px solid #FFEDD5;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: var(--shadow-soft);
}
.gas-label {
    font-size: 0.625rem; font-weight: 700; color: var(--text-light); letter-spacing: 0.05em; margin: 0;
}
.gas-value {
    font-size: 2rem; font-weight: 700; margin: 0.25rem 0 0 0; line-height: 1; color: var(--accent-orange);
}
.gas-unit {
    font-size: 0.75rem; color: var(--text-light); margin: 0;
}

.kitchen-devices {
    flex: 1.5;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.k-device-item {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    border: 1px solid #F3F4F6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-soft);
}


/* Animation Utils */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ==========================================================================
   DARK THEME
========================================================================== */
[data-theme="dark"] {
    --bg-main: #111827;
    --bg-card: #1F2937;
    --text-dark: #F9FAFB;
    --text-medium: #D1D5DB;
    --text-light: #9CA3AF;
    --bg-chat: #374151;
    --shadow-soft: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.5);
    background-color: var(--bg-main); /* Ensure body picks it up tightly */
}

/* Card Borders */
[data-theme="dark"] .card, 
[data-theme="dark"] .sensor-card,
[data-theme="dark"] .header {
    border: 1px solid #374151;
}

/* Specific Element Overrides */
[data-theme="dark"] .icon-circle,
[data-theme="dark"] .title-icon {
    background-color: var(--bg-chat);
    border-color: #4B5563;
}
[data-theme="dark"] .stat-pill {
    background: rgba(55, 65, 81, 0.5);
    border-color: #4B5563;
}
[data-theme="dark"] .pill-active {
    background: rgba(251, 146, 60, 0.15);
    border-color: #FB923C;
}
[data-theme="dark"] .device-item,
[data-theme="dark"] .qc-item,
[data-theme="dark"] .k-device-item,
[data-theme="dark"] .gas-block {
    background: #2D3748; /* slightly lighter than card */
    border-color: #4B5563;
}
[data-theme="dark"] .dropdown-menu {
    background: var(--bg-card);
    border-color: #374151;
}
[data-theme="dark"] .dropdown-menu a:hover {
    background: #374151;
}
[data-theme="dark"] .dropdown-menu hr {
    border-bottom-color: #374151;
}
[data-theme="dark"] .message-bubble:not([style*="background"]) {
    background: var(--bg-chat);
    border-color: #4B5563;
    color: var(--text-medium);
}
[data-theme="dark"] .bot-icon {
    background: var(--bg-chat);
    border-color: #4B5563;
}
[data-theme="dark"] .chat-input {
    background: #374151;
    border-color: #4B5563;
    color: var(--text-dark);
}
[data-theme="dark"] .carousel-controls button {
    background: #374151;
    color: var(--text-medium);
}
[data-theme="dark"] .carousel-controls button:hover {
    background: #4B5563;
}
[data-theme="dark"] .slider {
    background-color: #4B5563;
}

/* Kitchen Override for Dark Mode */
[data-theme="dark"] .kitchen-card {
    background-color: #2a1f1a;
    border-color: #4B5563;
}
[data-theme="dark"] .icon-orange-light {
    background: rgba(251, 146, 60, 0.2);
}
[data-theme="dark"] .badge-warning {
    background: rgba(251, 146, 60, 0.2);
}
