/* ==========================================================================
   BMS ONLINE DASHBOARD - GLASSMORPHISM STYLESHEET (MULTITENANT & FORMS)
   ========================================================================== */

:root {
    --bg-color: #080b16;
    --glass-bg: rgba(15, 22, 42, 0.45);
    --glass-bg-hover: rgba(20, 30, 58, 0.6);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-focus: rgba(0, 229, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    
    --accent-color: #00e5ff;
    --accent-glow: rgba(0, 229, 255, 0.3);
    --accent-gradient: linear-gradient(135deg, #00e5ff 0%, #0084ff 100%);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --color-temp: #ff5252;
    --color-temp-glow: rgba(255, 82, 82, 0.25);
    --color-light: #ffd740;
    --color-light-glow: rgba(255, 215, 64, 0.25);
    --color-security: #00e676;
    --color-security-glow: rgba(0, 230, 118, 0.25);
    --color-energy: #d500f9;
    --color-energy-glow: rgba(213, 0, 249, 0.25);
    
    --sidebar-width: 280px;
    --border-radius-lg: 20px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Background Glowing Orbs */
.glass-bg {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
    background: radial-gradient(circle at 10% 20%, rgba(0, 229, 255, 0.08) 0%, transparent 40%),
                radial-gradient(circle at 80% 80%, rgba(213, 0, 249, 0.08) 0%, transparent 45%),
                radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 1) 0%, rgba(8, 11, 22, 1) 100%);
}

/* 1. LOGIN OVERLAY DESIGN */
.login-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    background: rgba(8, 11, 22, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.login-card {
    width: 100%;
    max-width: 420px;
    padding: 40px 30px;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

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

.login-logo {
    font-size: 45px;
    color: var(--accent-color);
    margin-bottom: 12px;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.login-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #ffffff;
}

.login-header p {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-family: monospace;
}

.error-banner {
    background: rgba(255, 82, 82, 0.12);
    border: 1px solid rgba(255, 82, 82, 0.3);
    color: #ff5252;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
    line-height: 1.5;
}

/* Forms general */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group label i {
    margin-inline-end: 4px;
    color: var(--accent-color);
}

.form-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    outline: none;
    font-size: 14px;
    transition: var(--transition-fast);
}

.form-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.15);
}

/* 2. APP MAIN LAYOUT */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar styling */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(10, 15, 30, 0.7);
    border-inline-end: 1px solid var(--glass-border);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    position: relative;
}

.logo-glow {
    position: absolute;
    width: 45px;
    height: 45px;
    background: var(--accent-gradient);
    filter: blur(15px);
    opacity: 0.6;
    border-radius: 50%;
}

.logo-icon {
    font-size: 24px;
    color: var(--accent-color);
    z-index: 1;
}

.brand h1 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
    z-index: 1;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--border-radius-md);
    transition: var(--transition-normal);
    border: 1px solid transparent;
}

.nav-item i {
    font-size: 17px;
    transition: var(--transition-fast);
}

.nav-item:hover {
    color: var(--accent-color);
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.03);
    transform: translateX(-4px);
}

html[dir="ltr"] .nav-item:hover {
    transform: translateX(4px);
}

.nav-item.active {
    color: #ffffff;
    background: var(--glass-bg-hover);
    border-color: var(--glass-border);
    box-shadow: inset 0 0 12px rgba(0, 229, 255, 0.15);
    font-weight: 500;
}

.nav-item.active i {
    color: var(--accent-color);
    text-shadow: 0 0 8px var(--accent-glow);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.system-time {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 600;
    letter-spacing: 1px;
    background: rgba(255, 255, 255, 0.03);
    padding: 10px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--glass-border);
}

/* Main Content Wrapper */
.main-content {
    flex: 1;
    height: 100%;
    overflow-y: auto;
    padding: 30px;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Header actions bar */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.welcome-text h2 {
    font-size: 24px;
    font-weight: 700;
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.filter-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 6px 14px;
    border-radius: var(--border-radius-md);
}

.filter-wrapper label {
    font-size: 12px;
    color: var(--text-secondary);
}

.filter-wrapper label i {
    color: var(--accent-color);
}

.select-input {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 6px 12px;
    border-radius: var(--border-radius-sm);
    outline: none;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-fast);
}

/* Explicit options color styling to fix contrast issues in Windows dropdown overlays (User Request) */
.select-input option {
    background-color: #0d111c;
    color: #ffffff;
}

.select-input:focus {
    border-color: var(--accent-color);
}

/* Status Indicator */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 13px;
    font-weight: 600;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.status-good {
    background: rgba(0, 230, 118, 0.1);
    border: 1px solid rgba(0, 230, 118, 0.25);
    color: #00e676;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #00e676;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7);
    animation: pulse 1.6s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 230, 118, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(0, 230, 118, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(0, 230, 118, 0); }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-normal);
    border: 1px solid transparent;
}

.btn-primary {
    background: var(--accent-gradient);
    color: #000000;
    font-weight: 700;
}

.btn-primary:hover {
    box-shadow: 0 0 20px var(--accent-glow);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: rgba(255, 82, 82, 0.12);
    color: #ff5252;
    border-color: rgba(255, 82, 82, 0.25);
}

.btn-danger:hover {
    background: rgba(255, 82, 82, 0.25);
    box-shadow: 0 0 15px rgba(255, 82, 82, 0.2);
}

.btn-xs {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: var(--border-radius-sm);
}

.btn-full-width {
    width: 100%;
}

/* Glassmorphic Cards */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--glass-shadow);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 24px;
    transition: var(--transition-normal);
}

.glass-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

/* Tab Panes */
.tab-pane {
    display: none;
    flex-direction: column;
    gap: 30px;
    animation: fadeIn 0.4s ease forwards;
}

.tab-pane.active {
    display: flex;
}

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

/* Metrics Grid counters */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.metric-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.card-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid transparent;
}

.icon-temp { background: rgba(0, 229, 255, 0.1); color: var(--accent-color); border-color: rgba(0, 229, 255, 0.2); }
.icon-light { background: rgba(213, 0, 249, 0.1); color: var(--color-energy); border-color: rgba(213, 0, 249, 0.2); }
.icon-security { background: rgba(0, 230, 118, 0.1); color: var(--color-security); border-color: rgba(0, 230, 118, 0.2); }
.icon-energy { background: rgba(255, 215, 64, 0.1); color: var(--color-light); border-color: rgba(255, 215, 64, 0.2); }

.metric-info span {
    font-size: 12px;
    color: var(--text-secondary);
    display: block;
}

.metric-info h3 {
    font-size: 22px;
    font-weight: 700;
    margin-top: 4px;
}

/* Grid Layouts */
.layout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.glass-card h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 20px;
    color: #ffffff;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 12px;
}

/* Tables and Data lists */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 12px;
}

.section-header h3 {
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

.header-filters {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: start;
    font-size: 13px;
}

.data-table th {
    color: var(--text-secondary);
    font-weight: 600;
    padding: 14px 16px;
    border-bottom: 1px solid var(--glass-border);
}

.data-table td {
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.badge-admin { background: rgba(0, 229, 255, 0.15); color: var(--accent-color); }
.badge-user { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }

/* System Audit Logs List Widget */
.logs-container {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
}

.log-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: var(--border-radius-sm);
    border-inline-start: 3px solid var(--text-muted);
}

.log-item.log-info { border-color: var(--accent-color); }
.log-item.log-warning { border-color: var(--color-light); }
.log-item.log-danger { border-color: var(--color-temp); }

.log-time {
    color: var(--text-muted);
    font-family: monospace;
}

.log-text {
    color: var(--text-secondary);
}

/* MQTT Broker lists style */
.mqtt-broker-info-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.broker-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.broker-details h4 {
    font-size: 14px;
    font-weight: 600;
}

.broker-details p {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: monospace;
    margin-top: 4px;
}

.broker-status-badge {
    background: rgba(0, 230, 118, 0.12);
    color: #00e676;
    border: 1px solid rgba(0, 230, 118, 0.25);
}

/* MQTT Test Console Console window */
.mqtt-console-wrapper {
    background: #060913;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--glass-border);
    padding: 15px;
}

.mqtt-console {
    height: 380px;
    overflow: auto; /* Enables both vertical and horizontal scroll (User Request) */
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #a5b4fc;
}

.mqtt-line {
    padding: 4px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.02);
    line-height: 1.4;
    white-space: pre-wrap; /* Wrap long payloads onto multiple lines (User Request) */
    word-break: break-all; /* Break long contiguous strings like JSON to prevent stretching */
}

.mqtt-line-publish {
    color: #00e5ff;
}

.mqtt-line-subscribe {
    color: #ffd740;
}

.mqtt-line-time {
    color: var(--text-muted);
    margin-inline-end: 8px;
}

.mqtt-line-topic {
    font-weight: bold;
}

.mqtt-line-payload {
    color: #f8fafc;
    background: rgba(0, 0, 0, 0.25);
    padding: 8px 12px;
    border-radius: 4px;
    display: block;
    margin-top: 6px;
    max-width: 100%;
    white-space: pre-wrap; /* Wraps text onto multiple lines instead of scrolling horizontally (User Request) */
    word-break: break-all; /* Break long contiguous JSON strings to wrap safely */
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}



/* MQTT Publish History list items */
.history-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-fast);
    font-size: 11px;
    margin-bottom: 6px;
}

.history-item:hover {
    background: rgba(0, 229, 255, 0.08);
    border-color: rgba(0, 229, 255, 0.3);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-time {
    font-size: 9px;
    color: var(--text-muted);
    font-family: monospace;
}

.history-topic {
    color: var(--accent-color);
    font-weight: 600;
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.history-payload {
    color: var(--text-secondary);
    font-family: monospace;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}


/* 3. MODALS POPUP LAYOUT */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    width: 100%;
    max-width: 650px;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0,0,0,0.5);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--glass-border);
    padding-top: 16px;
    margin-top: 16px;
}

/* Checkbox lists */
.checkbox-list-container {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-md);
    padding: 12px;
    max-height: 120px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-secondary);
}

.checkbox-item input {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.text-danger { color: #ff5252 !important; }
.text-success { color: #00e676 !important; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* Responsive adjustments */
@media (max-width: 1024px) {
    .layout-grid { grid-template-columns: 1fr; }
    
    .sidebar {
        width: 80px;
        padding: 30px 10px;
        align-items: center;
    }
    
    .brand h1, .nav-item span, #lang-text { display: none; }
    .logo-glow { display: none; }
    
    .nav-item {
        padding: 13px;
        justify-content: center;
    }
    
    .nav-item:hover { transform: none; }
    .sidebar-footer { align-items: center; }
    .system-time { font-size: 10px; padding: 6px; }
    .main-content { padding: 20px; }
}

@media (max-width: 640px) {
    .app-container { flex-direction: column; }
    .form-grid { grid-template-columns: 1fr; }
    
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        justify-content: space-between;
        padding: 15px;
        border-inline-end: none;
        border-bottom: 1px solid var(--glass-border);
    }
    
    .brand { margin-bottom: 0; }
    
    .nav-menu {
        flex-direction: row;
        gap: 4px;
        justify-content: center;
        flex: initial;
    }
    
    .nav-item { padding: 8px 12px; }
    .sidebar-footer { flex-direction: row; margin-top: 0; gap: 8px; }
    .system-time { display: none; }
    .welcome-text h2 { font-size: 18px; }
}

/* MQTT Connection Status Badges */
.status-badge-connected {
    background: rgba(0, 230, 118, 0.12) !important;
    color: #00e676 !important;
    border: 1px solid rgba(0, 230, 118, 0.25) !important;
}

.status-badge-connecting {
    background: rgba(255, 215, 64, 0.12) !important;
    color: #ffd740 !important;
    border: 1px solid rgba(255, 215, 64, 0.25) !important;
}

.status-badge-disconnected {
    background: rgba(255, 82, 82, 0.12) !important;
    color: #ff5252 !important;
    border: 1px solid rgba(255, 82, 82, 0.25) !important;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-inline-end: 6px;
}
.status-dot-connected { background-color: #00e676; box-shadow: 0 0 8px rgba(0, 230, 118, 0.6); }
.status-dot-connecting { background-color: #ffd740; box-shadow: 0 0 8px rgba(255, 215, 64, 0.6); }
.status-dot-disconnected { background-color: #ff5252; box-shadow: 0 0 8px rgba(255, 82, 82, 0.6); }

