/* ============================================
   IoT DEVICE MANAGER - ПОЛНЫЙ ФАЙЛ СТИЛЕЙ
   Версия: 1.0
   ============================================ */

/* ============================================
   ПЕРЕМЕННЫЕ
   ============================================ */
:root {
    /* Цвета темы Neve */
    --nv-primary-accent: var(--nv-primary-accent, #0366d6);
    --nv-secondary-accent: var(--nv-secondary-accent, #fcaf3e);
    --nv-site-bg: var(--nv-site-bg, #ffffff);
    --nv-light-bg: var(--nv-light-bg, #f0f0f0);
    --nv-dark-bg: var(--nv-dark-bg, #1a1a1a);
    --nv-text-color: var(--nv-text-color, #404248);
    --nv-text-dark-bg: var(--nv-text-dark-bg, #ffffff);
    
    /* Цвета плагина */
    --iotdm-border: #e0e0e0;
    --iotdm-success: #28a745;
    --iotdm-danger: #dc3545;
    --iotdm-warning: #ffc107;
    
    /* Общие размеры шрифтов */
    --iotdm-fsize-buttons: 14px;
    --iotdm-fsize-buttons-small: 14px;
    --iotdm-fsize-buttons-table: 14px;
    --iotdm-fsize-buttons-detail: 14px;
    --iotdm-fsize-forms: 14px;
    --iotdm-fsize-hints: 11px;
    --iotdm-fsize-modal-title: 24px;
    --iotdm-fsize-table-header: 14px;
    --iotdm-fsize-table-data: 14px;
    
    /* Landing page шрифты */
    --iotdm-fsize-landing-hero-title: 42px;
    --iotdm-fsize-landing-hero-tagline: 18px;
    --iotdm-fsize-landing-feature-title: 18px;
    --iotdm-fsize-landing-feature-text: 14px;
    --iotdm-fsize-landing-button: 14px;
    
    /* Dashboard шрифты */
    --iotdm-fsize-sidebar-header: 18px;
    --iotdm-fsize-sidebar-device: 15px;
    --iotdm-fsize-sidebar-description: 11px;
    --iotdm-fsize-sidebar-buttons: 12px;
    --iotdm-fsize-sidebar-status: 10px;
    --iotdm-fsize-device-meta: 12px;
    --iotdm-fsize-device-tabs: 15px;
    --iotdm-fsize-detail-header: 15px;
    --iotdm-fsize-detail-label: 14px;
    --iotdm-fsize-detail-value: 14px;
    --iotdm-fsize-detail-status: 11px;

    /* Переменные кнопок Neve (с запасными значениями) */
    --btn-padding: 6px 12px;
    --btn-font-weight: 400;
    --btn-line-height: 1.6em;
    --btn-text-transform: none;
    --btn-letter-spacing: 0px;
    --btn-primary-border-width: 2px;
    --btn-secondary-border-width: 2px;
    --btn-primary-border-radius: 4px;
    --btn-secondary-border-radius: 4px;
}

/* ============================================
   СТИЛЬ 1: LANDING PAGE (неавторизованный пользователь)
   Класс: body.iotdm-landing-page
   ============================================ */

body.iotdm-landing-page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-y: auto;
}

body.iotdm-landing-page .site,
body.iotdm-landing-page .site-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin: 0;
    padding: 0;
}

body.iotdm-landing-page .entry-content {
    margin: 0;
    padding: 0;
}

/* Контейнер */
.iotdm-landing {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 20px 30px;
    width: 100%;
    box-sizing: border-box;
}

/* Hero-блок */
.iotdm-hero {
    text-align: center;
    padding: 40px 20px;
    background: var(--nv-dark-bg);
    color: var(--nv-text-dark-bg);
    margin-bottom: 40px;
    border-radius: 12px;
}

.iotdm-hero h1 {
    font-size: var(--iotdm-fsize-landing-hero-title, 42px);
    margin-bottom: 15px;
}

.iotdm-hero .tagline {
    font-size: var(--iotdm-fsize-landing-hero-tagline, 18px);
    margin-bottom: 25px;
    opacity: 0.9;
}

/* Кнопки входа */
.iotdm-login-box {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 10px;
}

/* Блоки преимуществ */
.iotdm-features {
    max-width: 1200px;
    margin: 0 auto 30px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
}

.iotdm-feature {
    text-align: center;
    padding: 30px 20px;
    background: var(--nv-light-bg);
    border-radius: 12px;
}

.iotdm-feature-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.iotdm-feature h3 {
    margin: 0 0 10px;
    font-size: var(--iotdm-fsize-landing-feature-title, 18px);
    color: var(--nv-text-color);
}

.iotdm-feature p {
    font-size: var(--iotdm-fsize-landing-feature-text, 14px);
    color: var(--nv-text-color);
    opacity: 0.7;
    line-height: 1.4;
}

/* Ссылка на документацию */
.iotdm-docs-link {
    max-width: 1200px;
    margin: 10px auto 20px;
    text-align: center;
}

/* Кнопка "Как это работает" */
.iotdm-button-outline {
    background: transparent;
    border: 2px solid var(--nv-primary-accent);
    color: var(--nv-primary-accent);
    display: inline-block;
    padding: 10px 28px;
    border-radius: 4px;
    text-decoration: none;
    font-size: var(--iotdm-fsize-landing-button, 14px);
    transition: all 0.3s ease;
    cursor: pointer;
}

.iotdm-button-outline:hover {
    background: var(--nv-primary-accent);
    color: #ffffff;
}

/* Планшеты */
@media (max-width: 1024px) {
    body.iotdm-landing-page .iotdm-features {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* Телефоны */
@media (max-width: 640px) {
    body.iotdm-landing-page .iotdm-landing {
        padding: 15px;
    }
    
    body.iotdm-landing-page .iotdm-hero {
        padding: 30px 15px;
        margin-bottom: 25px;
    }
    
    body.iotdm-landing-page .iotdm-hero h1 {
        font-size: 28px;
    }
    
    body.iotdm-landing-page .iotdm-hero .tagline {
        font-size: 14px;
    }
    
    body.iotdm-landing-page .iotdm-features {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-bottom: 20px;
    }
    
    body.iotdm-landing-page .iotdm-login-box {
        gap: 12px;
    }
    
    .iotdm-button-primary,
    .iotdm-button-secondary,
    .iotdm-button-outline {
        padding: 8px 20px;
        font-size: 13px;
    }
}

/* ============================================
   СТИЛЬ 2: DASHBOARD (авторизованный пользователь)
   Класс: body.iotdm-dashboard
   ============================================ */

/* Убираем прокрутку у body и html */
body.iotdm-dashboard {
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* Убираем ограничения ширины */
body.iotdm-dashboard .container,
body.iotdm-dashboard .container-fluid,
body.iotdm-dashboard .nv-single-page-wrap,
body.iotdm-dashboard .nv-content-wrap {
    max-width: 100% !important;
    width: 100% !important;
}

/* Фиксируем высоту wrapper */
body.iotdm-dashboard .wrapper {
    height: 100vh !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

body.admin-bar.iotdm-dashboard .wrapper {
    height: calc(100vh - 32px) !important;
    margin-top: 0 !important;
}

/* Шапка и подвал не сжимаются */
body.iotdm-dashboard .site-header,
body.iotdm-dashboard .site-footer {
    flex: 0 0 auto !important;
    margin-bottom: 0 !important;
    position: relative !important;
    bottom: 0 !important;
    z-index: 1 !important;
}

/* Основной контент растягивается */
body.iotdm-dashboard .site-content {
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* Контейнеры внутри основного контента */
body.iotdm-dashboard .neve-main,
body.iotdm-dashboard .neve-main .container-fluid,
body.iotdm-dashboard .neve-main .row,
body.iotdm-dashboard .neve-main .nv-single-page-wrap,
body.iotdm-dashboard .neve-main .nv-content-wrap {
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Контейнер плагина */
.iotdm-container {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--nv-site-bg);
}

/* Контейнер с двумя панелями */
.iotdm-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    overflow: hidden;
    background: var(--nv-site-bg);
}

/* ========== ЛЕВАЯ ПАНЕЛЬ ========== */
.iotdm-sidebar {
    width: 320px;
    min-width: 280px;
    background-color: var(--nv-dark-bg, #1a472a);
    color: var(--nv-text-dark-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.iotdm-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.iotdm-sidebar-header h2 {
    margin: 0;
    font-size: var(--iotdm-fsize-sidebar-header, 18px);
    color: var(--nv-text-dark-bg);
}

.iotdm-button-add {
    background: var(--nv-secondary-accent);
    color: #ffffff;
    font-size: var(--iotdm-fsize-buttons-small, 12px);
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Список устройств - прокрутка */
.iotdm-devices-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 10px;
}

.iotdm-empty-devices {
    text-align: center;
    padding: 30px 20px;
    color: rgba(255,255,255,0.7);
}

/* Карточка устройства */
.iotdm-device-item {
    padding: 10px 12px;
    margin-bottom: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
}

.iotdm-device-item:hover {
    background: rgba(255,255,255,0.2);
}

.iotdm-device-item.active {
    background: var(--nv-secondary-accent);
    border-left: 3px solid var(--iotdm-warning);
}

.iotdm-device-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.iotdm-device-name {
    font-weight: bold;
    font-size: var(--iotdm-fsize-sidebar-device, 15px);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--nv-text-dark-bg);
}

.iotdm-device-header-actions {
    display: flex;
    gap: 6px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.iotdm-device-item:hover .iotdm-device-header-actions {
    opacity: 1;
}

.iotdm-device-header-actions button {
    background: none;
    border: none;
    color: var(--nv-text-dark-bg);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: var(--iotdm-fsize-sidebar-buttons, 12px);
}

.iotdm-device-header-actions button:hover {
    background: rgba(255,255,255,0.2);
}

.iotdm-device-footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--iotdm-fsize-sidebar-description, 11px);
    opacity: 0.8;
}

.iotdm-device-description {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    color: var(--nv-text-dark-bg);
}

.iotdm-status-icon {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* dashboard.php :: иконка статуса */
.status-active {
    color: #00ff00; /* Зеленый - активно */
}

.status-warning {
    color: #ffaa00; /* Желтый - более часа нет данных */
}

.status-inactive {
    color: #ff0000; /* Красный - нет данных */
}

.status-time {
    font-size: var(--iotdm-fsize-sidebar-status, 10px);
    color: var(--nv-text-dark-bg);
}

/* ========== ПРАВАЯ ПАНЕЛЬ ========== */
.iotdm-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    background: var(--nv-site-bg);
    padding: 20px;
}

/* ========== ЗАГОЛОВОК УСТРОЙСТВА ========== */
.iotdm-device-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--iotdm-border);
}

.iotdm-device-header h2 {
    margin: 0 0 10px;
    color: var(--nv-text-color);
}

.device-description {
    color: var(--nv-text-color);
    opacity: 0.7;
    margin-bottom: 10px;
}

.iotdm-device-meta {
    display: flex;
    gap: 20px;
    font-size: var(--iotdm-fsize-device-meta, 12px);
    color: var(--nv-text-color);
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.iotdm-device-meta-left {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.iotdm-device-meta code {
    background: var(--nv-light-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--nv-text-color);
}

/* dashboard.php :: подсказка об ограничениях */
.iotdm-device-limits-hint {
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--nv-light-bg);
    border-radius: 4px;
    font-size: 12px;
    color: var(--nv-text-color);
    opacity: 0.7;
}

.iotdm-device-limits-hint small {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ========== ВКЛАДКИ ========== */
.iotdm-tabs {
    display: flex;
    gap: 5px;
    border-bottom: 2px solid var(--iotdm-border);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.iotdm-tab {
    padding: 10px 20px;
    background: var(--nv-light-bg, none);
    border: none;
    cursor: pointer;
    font-size: var(--iotdm-fsize-device-tabs, 14px);
    color: var(--nv-text-color);
    /* opacity: 0.7; */
    transition: all 0.3s;
}

.iotdm-tab:hover {
    opacity: 1;
    color: var(--nv-primary-accent);
}

.iotdm-tab.active {
    opacity: 1;
    color: var(--nv-primary-accent);
    border-bottom: 2px solid var(--nv-primary-accent);
    margin-bottom: -2px;
}

.iotdm-tab-content {
    display: none;
}

.iotdm-tab-content.active {
    display: block;
}

/* ========== ТАБЛИЦА ДАННЫХ ========== */

.iotdm-data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.iotdm-data-perpage {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--iotdm-fsize-table-header, 13px);
    color: var(--nv-text-color);
}

.iotdm-data-perpage label {
    margin: 0;
}

.iotdm-data-perpage select {
    padding: 6px 10px;
    border: 1px solid var(--iotdm-border);
    border-radius: 4px;
    background: var(--nv-site-bg);
    color: var(--nv-text-color);
    cursor: pointer;
}

.iotdm-data-table-wrapper {
    overflow-x: auto;
}

.iotdm-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--iotdm-fsize-table-data, 13px);
    min-width: 600px;
}

.iotdm-data-table th,
.iotdm-data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--iotdm-border);
    color: var(--nv-text-color);
}

.iotdm-data-table th {
    background: var(--nv-light-bg);
    font-weight: 600;
}

/* Фиксированная ширина для колонки времени */
.iotdm-data-table .col-time {
    white-space: nowrap;
    width: 1%;
}

/* Фиксированная ширина для колонок данных */
.iotdm-data-table .col-data {
    white-space: nowrap;
    min-width: 100px;
    width: auto;
}

/* Для таблицы на мобильных устройствах */
@media (max-width: 768px) {
    .iotdm-data-table .col-data {
        min-width: 80px;
    }
}

/* ========== ПАГИНАЦИЯ ========== */
.iotdm-pagination {
    margin-top: 20px;
    display: flex;
    gap: 5px;
    justify-content: center;
    flex-wrap: wrap;
}

.iotdm-page-btn {
    padding: 5px 12px;
    background: var(--nv-light-bg);
    border: 1px solid var(--iotdm-border);
    border-radius: 4px;
    cursor: pointer;
    color: var(--nv-text-color);
}

.iotdm-page-btn.active {
    background: var(--nv-primary-accent);
    color: #ffffff;
}

/* ========== КНОПКИ ========== */
/* Все текстовые кнопки наследуют стили темы Neve */
.iotdm-button {
    display: inline-block;
    cursor: pointer;
    padding: var(--btn-padding, 12px 24px);
    border-radius: var(--btn-primary-border-radius, 4px);
    font-size: var(--iotdm-fsize-buttons, 14px);
    font-weight: var(--btn-font-weight, 600);
    line-height: var(--btn-line-height, 1.6em);
    text-transform: var(--btn-text-transform, none);
    letter-spacing: var(--btn-letter-spacing, 0px);
    transition: all 0.3s ease;
    text-decoration: none;
}

/* Основная кнопка (акцент) */
.iotdm-button-primary {
    background: var(--nv-primary-accent);
    color: #ffffff;
    border: var(--btn-primary-border-width, 2px) solid var(--nv-primary-accent);
}

.iotdm-button-primary:hover {
    background: var(--nv-secondary-accent);
    border-color: var(--nv-secondary-accent);
    color: #ffffff;
    opacity: 1;
}

/* Второстепенная кнопка */
.iotdm-button-secondary {
    background: var(--secondarybtnbg, rgba(0,0,0,0));
    color: var(--nv-primary-accent);
    border: var(--btn-secondary-border-width, 2px) solid var(--nv-primary-accent);
}

.iotdm-button-secondary:hover {
    background: var(--nv-primary-accent);
    color: #ffffff;
}

/* Опасная кнопка (удаление) */
.iotdm-button-danger {
    background: var(--iotdm-danger);
    color: #ffffff;
    border: 2px solid var(--iotdm-danger);
}

.iotdm-button-danger:hover {
    background: #c82333;
    border-color: #c82333;
    color: #ffffff;
}

/* Маленькая кнопка */
.iotdm-button-small {
    padding: var(--btn-padding, 12px 24px);
    font-size: var(--iotdm-fsize-buttons-small, 12px);
}

/* Кнопка добавления устройства */
.iotdm-button-add {
    background: var(--nv-secondary-accent);
    color: #ffffff;
    border: none;
    padding: 6px 12px;
    font-size: var(--iotdm-fsize-buttons-small, 12px);
    border-radius: var(--btn-primary-border-radius, 4px);
}

.iotdm-button-add:hover {
    background: var(--nv-primary-accent);
    color: #ffffff;
}

/* Кнопка с обводкой (для landing page) */
.iotdm-button-outline {
    background: transparent;
    border: 2px solid var(--nv-primary-accent);
    color: var(--nv-primary-accent);
}

.iotdm-button-outline:hover {
    background: var(--nv-primary-accent);
    color: #ffffff;
}

/* Кнопка очистки данных */
.iotdm-clear-data-btn {
    background: var(--iotdm-danger);
    color: #ffffff;
    border: none;
    padding: 4px 12px;
    border-radius: var(--btn-primary-border-radius, 4px);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.iotdm-clear-data-btn:hover {
    background: #c82333;
}

/* ========== ДИАГНОСТИКА ========== */

.iotdm-diagnostics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.iotdm-diagnostics-perpage {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--iotdm-fsize-table-header, 13px);
    color: var(--nv-text-color);
}

.iotdm-diagnostics-perpage label {
    margin: 0;
}

.iotdm-diagnostics-perpage select {
    padding: 6px 10px;
    border: 1px solid var(--iotdm-border);
    border-radius: 4px;
    background: var(--nv-site-bg);
    color: var(--nv-text-color);
    cursor: pointer;
}

.iotdm-diagnostics-table-wrapper {
    overflow-x: auto;
}

.iotdm-diagnostics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--iotdm-fsize-table-data, 13px);
    min-width: 800px;
}

.iotdm-diagnostics-table th,
.iotdm-diagnostics-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--iotdm-border);
    color: var(--nv-text-color);
}

.iotdm-diagnostics-table th {
    background: var(--nv-light-bg);
    font-weight: 600;
}

.iotdm-diagnostics-table .col-time {
    white-space: nowrap;
    width: 1%;
}

.iotdm-diagnostics-table .col-errors {
    white-space: nowrap;
    width: 1%;
}

.iotdm-diagnostics-table .col-memory {
    white-space: nowrap;
    width: 1%;
}

.iotdm-diagnostics-table .col-cpu {
    white-space: nowrap;
    width: 1%;
}

.iotdm-diagnostics-table .col-rssi {
    white-space: nowrap;
    width: 1%;
}

.iotdm-diagnostics-table .col-actions {
    white-space: nowrap;
    width: 1%;
}

.iotdm-diagnostics-table .col-actions button {
    margin: 0 2px;
}

/* ========== ЖУРНАЛ СОБЫТИЙ ========== */

/* Унификация с таблицей данных */
.iotdm-logs-table-wrapper {
    overflow-x: auto;
}

.iotdm-logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--iotdm-fsize-table-data, 13px);
}

.iotdm-logs-table th,
.iotdm-logs-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--iotdm-border);
    color: var(--nv-text-color);
}

.iotdm-logs-table th {
    background: var(--nv-light-bg);
    font-weight: 600;
}

.iotdm-logs-table tr:hover {
    background: var(--nv-light-bg);
}

/* Фиксированная ширина для колонки "Время" */
.iotdm-logs-table th:first-child,
.iotdm-logs-table td:first-child {
    white-space: nowrap;
    width: 1%;
}

/* Фиксированная ширина для колонки "Тип" */
.iotdm-logs-table th:nth-child(2),
.iotdm-logs-table td:nth-child(2) {
    white-space: nowrap;
    width: 1%;
}

/* Колонка "Сообщение" занимает всё оставшееся место */
.iotdm-logs-table th:nth-child(3),
.iotdm-logs-table td:nth-child(3) {
    width: 98%;
    word-break: break-word;
}

/* Стили для типов сообщений (только цвет иконки и текста типа) */
.log-type-info td:nth-child(2) {
    color: #2196f3;
}

.log-type-ok td:nth-child(2) {
    color: #4caf50;
}

.log-type-warning td:nth-child(2) {
    color: #ff9800;
}

.log-type-error td:nth-child(2) {
    color: #f44336;
}

/* Заголовок таблицы логов - унификация с data-header */
.iotdm-logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.iotdm-logs-filter,
.iotdm-logs-perpage {
    display: flex;
    align-items: center;
    gap: 10px;
}

.iotdm-logs-filter label,
.iotdm-logs-perpage label {
    margin: 0;
    font-size: var(--iotdm-fsize-table-header, 13px);
    color: var(--nv-text-color);
}

.iotdm-logs-filter select,
.iotdm-logs-perpage select {
    padding: 6px 10px;
    border: 1px solid var(--iotdm-border);
    border-radius: 4px;
    background: var(--nv-site-bg);
    color: var(--nv-text-color);
    font-size: var(--iotdm-fsize-table-data, 13px);
    cursor: pointer;
}

.iotdm-logs-filter button {
    margin-left: 10px;
}

/* ========== ФОРМЫ ========== */
.iotdm-form-group {
    margin-bottom: 15px;
}

.iotdm-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--nv-text-color);
}

.iotdm-form-group input,
.iotdm-form-group textarea,
.iotdm-form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--iotdm-border);
    border-radius: 4px;
    font-size: var(--iotdm-fsize-forms, 14px);
    background: var(--nv-site-bg);
    color: var(--nv-text-color);
}

.iotdm-form-group .description {
    font-size: var(--iotdm-fsize-hints, 11px);
    color: var(--nv-text-color);
    opacity: 0.7;
    margin-top: 4px;
    margin-bottom: 0;
}

/* ========== МОДАЛЬНЫЕ ОКНА ========== */
.iotdm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
}

.iotdm-modal.hidden {
    display: none;
}

.iotdm-modal-content {
    background: var(--nv-site-bg);
    border-radius: 8px;
    width: 720px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

#iotdm-field-modal .iotdm-modal-content {
    width: 500px;
}

.iotdm-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--iotdm-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.iotdm-modal-header h3 {
    margin: 0;
    color: var(--nv-text-color);
}

.iotdm-modal-close {
    font-size: var(--iotdm-fsize-modal-title, 24px);
    cursor: pointer;
    color: var(--nv-text-color);
    opacity: 0.7;
}

.iotdm-modal-close:hover {
    opacity: 1;
    color: var(--iotdm-danger);
}

.iotdm-modal-body {
    padding: 20px;
}

.iotdm-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--iotdm-border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Стили для чекбокса в модальном окне */
.iotdm-form-group-inline-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 15px;
}

.iotdm-form-group-inline-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin: 0;
    font-weight: 500;
}

.iotdm-form-group-inline-checkbox .description {
    flex: 1;
    margin: 0;
    font-size: var(--iotdm-fsize-hints, 11px);
    color: var(--nv-text-color);
    opacity: 0.7;
}

/* ========== КАРТОЧКИ УВЕДОМЛЕНИЙ И ТРАНЗИТОВ ========== */
.iotdm-notification-item,
.iotdm-forwarding-item {
    background: var(--nv-light-bg);
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 10px;
}

.notif-header,
.fw-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.notif-header strong,
.fw-header strong {
    font-size: var(--iotdm-fsize-detail-header, 14px);
}

.notif-header-actions,
.fw-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.notif-status,
.fw-status {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: var(--iotdm-fsize-detail-status, 11px);
    font-weight: 500;
}

.notif-status.enabled,
.fw-status.enabled {
    background: var(--iotdm-success);
    color: #ffffff;
}

.notif-status.disabled,
.fw-status.disabled {
    background: var(--iotdm-danger);
    color: #ffffff;
}

.notif-details,
.fw-details {
    margin-top: 8px;
}

.notif-detail-row,
.fw-detail-row {
    display: flex;
    align-items: baseline;
    margin-bottom: 6px;
    gap: 15px;
}

.notif-detail-label,
.fw-detail-label {
    font-weight: 500;
    min-width: 150px;
    color: var(--nv-text-color);
    opacity: 0.7;
    font-size: var(--iotdm-fsize-detail-label, 12px);
}

.notif-detail-value,
.fw-detail-value {
    flex: 1;
    color: var(--nv-text-color);
    font-size: var(--iotdm-fsize-detail-value, 13px);
    word-break: break-all;
    background: var(--nv-site-bg);
    border-radius: 4px;
    padding: 6px 10px;
}

.notif-header-actions button,
.fw-header-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: var(--iotdm-fsize-buttons-detail, 13px);
    color: var(--nv-text-color);
    opacity: 0.6;
}

.notif-header-actions button:hover,
.fw-header-actions button:hover {
    opacity: 1;
    background: rgba(0,0,0,0.1);
}

.notif-header-actions .delete-notification:hover,
.fw-header-actions .delete-forwarding:hover {
    color: var(--iotdm-danger);
}

/* ========== ТАБЛИЦА ПОЛЕЙ ========== */
.iotdm-fields-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--iotdm-fsize-table-data, 13px);
}

.iotdm-fields-table th,
.iotdm-fields-table td {
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--iotdm-border);
    color: var(--nv-text-color);
}

.iotdm-fields-table th {
    background: var(--nv-light-bg);
    font-weight: 600;
    font-size: var(--iotdm-fsize-table-header, 12px);
}

.iotdm-fields-table .edit-field,
.iotdm-fields-table .delete-field {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: var(--iotdm-fsize-buttons-table, 12px);
    color: var(--nv-text-color);
    opacity: 0.6;
}

.iotdm-fields-table .edit-field:hover,
.iotdm-fields-table .delete-field:hover {
    opacity: 1;
    background: var(--nv-light-bg);
}

.iotdm-fields-table .delete-field:hover {
    color: var(--iotdm-danger);
}

.iotdm-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 10px;
}

.iotdm-section-header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

.iotdm-section-header h3 {
    margin: 0;
    font-size: var(--iotdm-fsize-detail-header, 14px);
    color: var(--nv-text-color);
}

/* ========== НАСТРОЙКИ УСТРОЙСТВА ========== */
.iotdm-settings-panel {
    display: flex;
    flex-direction: column;
    min-height: 400px;
}

.iotdm-settings-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--iotdm-border);
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.iotdm-setting-group {
    margin-bottom: 15px;
    padding: 12px;
    background: var(--nv-light-bg);
    border-radius: 6px;
}

/* Группа настроек в стиле карточек уведомлений */
.iotdm-setting-row {
    display: flex;
    align-items: baseline;
    margin-top: 15px;
    gap: 15px;
}

.iotdm-setting-group header {
    font-weight: bold;
    font-size: var(--iotdm-fsize-detail-header, 14px);
    min-width: 150px;
    display: block;
    margin-bottom: 8px;
    color: var(--nv-text-color);
}

.iotdm-setting-label {
    font-weight: bold;
    font-size: var(--iotdm-fsize-detail-label, 12px);
    color: var(--nv-text-color);
    /* opacity: 0.7; */
    min-width: 150px;
} 

.iotdm-setting-value {
    flex: 1;
    color: var(--nv-text-color);
    font-size: var(--iotdm-fsize-detail-value, 13px);
    word-break: break-all;
    background: var(--nv-site-bg);
    border-radius: 4px;
    padding: 6px 10px;
}

.iotdm-setting-description {
    font-size: var(--iotdm-fsize-hints, 11px);
    color: var(--nv-text-color);
    /* opacity: 0.7; */
    margin-top: 0;
    margin-left: 0;
    margin-bottom: 0;
}

.iotdm-setting-group-inline {
    display: flex;
    /* justify-content: space-between; */
    align-items: center;
    margin-bottom: 15px;
    padding: 12px;
    background: var(--nv-light-bg);
    border-radius: 6px;
    flex-wrap: wrap;
    gap: 10px;
}

.iotdm-setting-group-inline label {
    font-weight: bold;
    font-size: var(--iotdm-fsize-detail-label, 12px);
    color: var(--nv-text-color);
    min-width: 150px;
    margin: 0;
}

.iotdm-setting-group-inline .setting-value {
    flex: 1;
    color: var(--nv-text-color);
    font-size: var(--iotdm-fsize-detail-value, 13px);
    word-break: break-all;
    background: var(--nv-site-bg);
    border-radius: 4px;
    padding: 6px 10px;
}

.regenerate-token {
    background: transparent !important;
    border: 1px solid var(--iotdm-border) !important;
    margin-left: 8px;
    padding: 4px 8px !important;
    font-size: 14px !important;
}

.regenerate-token:hover {
    background: var(--nv-light-bg) !important;
    border-color: var(--nv-primary-accent) !important;
}

/* ========== РАЗДЕЛИТЕЛЬ ПАНЕЛЕЙ ========== */
.iotdm-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    transition: background 0.2s;
    z-index: 10;
}

.iotdm-resizer:hover {
    background: var(--nv-primary-accent);
}

/* ========== ПРОКРУТКА ========== */
body.iotdm-dashboard .iotdm-devices-list {
    flex: 1 !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}

body.iotdm-dashboard .iotdm-content {
    flex: 1 !important;
    overflow-y: auto !important;
    min-height: 0 !important;
}

/* ========== ВСПЛЫВАЮЩИЕ УВЕДОМЛЕНИЯ ========== */
.iotdm-notice {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    background: var(--iotdm-success);
    color: white;
    border-radius: 6px;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

.iotdm-notice.error {
    background: var(--iotdm-danger);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========== ВСПОМОГАТЕЛЬНЫЕ СТИЛИ ========== */
.iotdm-welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: var(--nv-text-color);
    opacity: 0.7;
}

.iotdm-loading {
    text-align: center;
    padding: 40px;
    color: var(--nv-text-color);
    opacity: 0.7;
}

/* ========== МОБИЛЬНАЯ ВЕРСИЯ DASHBOARD ========== */
@media (max-width: 768px) {
    body.iotdm-dashboard .wrapper {
        height: auto !important;
        overflow: auto !important;
    }
    
    .iotdm-wrapper {
        flex-direction: column;
    }
    
    .iotdm-sidebar {
        width: 100%;
        min-width: auto;
        max-height: 40vh;
    }
    
    .iotdm-content {
        min-height: 60vh;
    }
    
    .iotdm-resizer {
        display: none;
    }
    
    .iotdm-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }
    
    .iotdm-settings-footer {
        flex-direction: column;
    }
    
    .iotdm-settings-footer .iotdm-button {
        width: 100%;
    }
}