/* ==========================================================================
   LoggerFlex MQTT Portal Stylesheet
   Theme: Glassmorphism / Cyberpunk Dark
   ========================================================================== */

:root {
    /* Color Palette */
    --bg-dark: #070913;
    --card-bg: rgba(16, 20, 38, 0.6);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-hover-border: rgba(99, 102, 241, 0.3);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --primary: #6366f1; /* Indigo */
    --primary-glow: rgba(99, 102, 241, 0.4);
    --secondary: #14b8a6; /* Teal */
    --secondary-glow: rgba(20, 184, 166, 0.4);

    --success: #10b981; /* Emerald */
    --success-glow: rgba(16, 185, 129, 0.3);
    --danger: #ef4444; /* Red */
    --danger-glow: rgba(239, 68, 68, 0.3);
    --warning: #f59e0b; /* Amber */

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Drifting Lights */
.bg-glows {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: drift 20s infinite alternate ease-in-out;
}

.glow-1 {
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
    top: -10vw;
    left: -10vw;
}

.glow-2 {
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--secondary) 0%, transparent 70%);
    bottom: -15vw;
    right: -10vw;
    animation-delay: -5s;
    animation-duration: 25s;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 10%) scale(1.1); }
}

/* Glassmorphism Panel Utility */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Screens Wrapper */
.screen {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    opacity: 1;
}

#dashboard-screen.screen.active {
    display: block;
    padding: 24px;
}

/* ==========================================================================
   1. LOGIN SCREEN STYLES
   ========================================================================== */
#login-screen {
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px var(--primary-glow);
}

.logo-icon i {
    font-size: 28px;
    color: white;
}

.login-header h1 {
    font-family: var(--font-heading);
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* Form Styling */
.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 16px;
    color: var(--text-muted);
    font-size: 16px;
}

.input-wrapper input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    background: rgba(31, 41, 55, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    color: white;
    font-size: 15px;
    font-family: var(--font-body);
    transition: all 0.3s ease;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(31, 41, 55, 0.6);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    border: none;
    border-radius: 12px;
    color: white;
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px var(--primary-glow);
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.6);
}

.btn-primary:active {
    transform: translateY(0);
}

.error-message {
    display: none;
    align-items: center;
    gap: 8px;
    color: #f87171;
    font-size: 13px;
    margin-bottom: 20px;
    background: rgba(239, 68, 68, 0.1);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   2. DASHBOARD NAVIGATION BAR
   ========================================================================== */
.navbar {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto 24px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-left i {
    font-size: 22px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-animated {
    animation: wave 2s infinite ease-in-out;
}

@keyframes wave {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 0px transparent); }
    50% { transform: scale(1.15); filter: drop-shadow(0 0 8px var(--primary-glow)); }
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
}

.divider {
    color: var(--text-muted);
    font-weight: 300;
}

.portal-badge {
    font-size: 13px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--card-border);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Status Badges */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-badge.connected {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.connected .status-dot {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success-glow);
    animation: pulse 1.5s infinite;
}

.status-badge.disconnected {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-badge.disconnected .status-dot {
    background-color: var(--danger);
    box-shadow: 0 0 8px var(--danger-glow);
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

/* ==========================================================================
   DASHBOARD GRID & CARDS
   ========================================================================== */
.dashboard-grid {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.telemetry-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

/* Individual Card Styling */
.card {
    position: relative;
    padding: 24px;
    overflow: hidden;
}

.card:hover {
    border-color: var(--card-hover-border);
    box-shadow: 0 12px 40px 0 rgba(99, 102, 241, 0.05);
}

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

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.icon-temp {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.icon-rh {
    background: rgba(20, 184, 166, 0.1);
    color: var(--secondary);
    border: 1px solid rgba(20, 184, 166, 0.2);
}

.icon-hw {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.icon-chart {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.icon-controls {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.icon-console {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--card-border);
}

.card-header h3 {
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.card-body {
    position: relative;
    z-index: 1;
}

/* Numeric Value Display */
.value-display {
    display: flex;
    align-items: baseline;
    margin-bottom: 16px;
}

.value-display .value {
    font-family: var(--font-heading);
    font-size: 48px;
    font-weight: 800;
    letter-spacing: -1px;
}

.value-display .unit {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 4px;
}

.card-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Helpers for stats coloring */
.text-red { color: #f87171; }
.text-blue { color: #60a5fa; }
.font-mono { font-family: monospace; }

/* Info list style for status card */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.info-item .label {
    color: var(--text-secondary);
}

.info-item .value-text {
    font-weight: 500;
}

/* Device status indicator badge */
.device-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    width: 100%;
    justify-content: center;
    border: 1px solid var(--card-border);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.device-status-badge.online {
    background: rgba(16, 185, 129, 0.08);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
}

.device-status-badge.online .pulse-dot {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
    animation: pulse 1.5s infinite;
}

.device-status-badge.offline {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}

.device-status-badge.offline .pulse-dot {
    background-color: var(--danger);
    box-shadow: 0 0 8px var(--danger);
}

/* Card Glow Overlays */
.card-glow {
    position: absolute;
    top: -50px;
    right: -50px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.15;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.temp-glow { background-color: var(--danger); }
.rh-glow { background-color: var(--secondary); }
.hw-glow { background-color: var(--primary); }

.card:hover .card-glow {
    opacity: 0.3;
}

/* ==========================================================================
   CHARTS & CONTROLS ROW
   ========================================================================== */
.charts-controls-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .charts-controls-row {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    min-height: 380px;
    display: flex;
    flex-direction: column;
}

.chart-container {
    flex-grow: 1;
    position: relative;
    height: 280px;
    width: 100%;
}

/* Control Panel styles */
.control-card {
    display: flex;
    flex-direction: column;
}

.control-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.control-info {
    max-width: 70%;
}

.control-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.control-desc {
    font-size: 11px;
    color: var(--text-secondary);
}

.switch-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.switch-status {
    font-size: 11px;
    font-weight: 700;
    font-family: monospace;
}

/* Custom CSS Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--card-border);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.toggle-switch input:checked + .slider {
    background-color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.toggle-switch input:checked + .slider:before {
    transform: translateX(24px);
}

.control-divider {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin: 8px 0 20px;
}

/* Momentary Action Button */
.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-secondary:active {
    transform: scale(0.97);
}

/* ==========================================================================
   CONSOLE LOGS CARD
   ========================================================================== */
.console-card {
    margin-bottom: 24px;
}

.console-card .card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.btn-clear {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.3s ease;
}

.btn-clear:hover {
    color: var(--danger);
}

.logs-container {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    height: 120px;
    overflow-y: auto;
    padding: 12px;
    font-family: monospace;
    font-size: 12px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-line {
    word-break: break-all;
}

.log-line .timestamp {
    color: var(--text-muted);
    margin-right: 8px;
}

.log-line.system { color: #38bdf8; }
.log-line.send { color: #f472b6; }
.log-line.recv { color: #34d399; }
.log-line.err { color: #f87171; }

/* Pulse animation helper */
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.4; }
    100% { transform: scale(1); opacity: 1; }
}

/* Entry Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   3. SIMULATOR & DATA CALCULATOR STYLES
   ========================================================================== */
.icon-simulator {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.simulator-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .simulator-layout {
        grid-template-columns: 1fr;
    }
}

.sim-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sim-toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid var(--card-border);
}

.sim-input-row {
    display: flex;
    gap: 16px;
}

.sim-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sim-input-group.full-width {
    flex: none;
    width: 100%;
}

.sim-input-group label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.sim-input-group input, .sim-input-group select {
    padding: 10px 12px;
    background: rgba(31, 41, 55, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    transition: all 0.3s ease;
}

.sim-input-group input:focus, .sim-input-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.stats-column {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 16px;
}

.usage-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.usage-stat-box {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.usage-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.usage-val {
    font-size: 15px;
    font-weight: 700;
    color: var(--secondary);
}

.projection-box {
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.projection-box h4 {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 4px;
}

.projection-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.projection-row span {
    color: var(--text-secondary);
}

.projection-row strong {
    color: var(--primary);
    font-weight: 600;
}

.projection-note {
    font-size: 9px;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 4px;
}

