/* ========================================
   IoT СУПЕРПАНЕЛЬ - ЕДИНЫЙ СТИЛЬ
   Тёмная и светлая темы
   ======================================== */

/* ---------- ТЁМНАЯ ТЕМА (по умолчанию) ---------- */
:root {
    --bg-main: #0a0e12;
    --bg-panel: #161b22;
    --bg-card: #1a1f2e;
    --bg-card-secondary: #21262d;
    --bg-input: #2d2d3d;
    --bg-hover: #30363d;

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: white;

    --accent: #58a6ff;
    --accent-gradient-start: #58a6ff;
    --accent-gradient-end: #1f6feb;
    --accent-hover: #79c0ff;

    --border: #30363d;
    --border-light: #21262d;

    --success: #3fb950;
    --success-bg: rgba(63, 185, 80, 0.15);
    --warning: #d29922;
    --warning-bg: rgba(210, 153, 34, 0.15);
    --error: #f85149;
    --error-bg: rgba(248, 81, 73, 0.15);
    --info: #58a6ff;
    --info-bg: rgba(88, 166, 255, 0.15);
}

/* ---------- СВЕТЛАЯ ТЕМА ---------- */
body.light {
    --bg-main: #f0f2f5;
    --bg-panel: #ffffff;
    --bg-card: #ffffff;
    --bg-card-secondary: #f6f8fa;
    --bg-input: #eef2f5;
    --bg-hover: #e4e9f0;

    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #00315c;

    --accent: #0969da;
    --accent-gradient-start: #0969da;
    --accent-gradient-end: #1f6feb;
    --accent-hover: #1f6feb;

    --border: #d0d7de;
    --border-light: #e9ecef;

    --success: #1a7f37;
    --success-bg: rgba(26, 127, 55, 0.1);
    --warning: #9a6700;
    --warning-bg: rgba(154, 103, 0, 0.1);
    --error: #cf222e;
    --error-bg: rgba(207, 34, 46, 0.1);
    --info: #0969da;
    --info-bg: rgba(9, 105, 218, 0.1);
}

/* ---------- БАЗОВЫЕ СТИЛИ ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    padding: 16px;
    transition: background 0.3s ease, color 0.3s ease;
}

@media (min-width: 768px) {
    body {
        padding: 24px;
    }
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ---------- ЗАГОЛОВКИ ---------- */
h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

@media (min-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.25rem 0 0.75rem 0;
    color: var(--text-primary);
    border-left: 3px solid var(--accent);
    padding-left: 0.75rem;
}

/* ---------- СЕТКИ ---------- */
.sensors-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.875rem;
    margin-top: 1rem;
}

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

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

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

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

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

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

/* ---------- КАРТОЧКИ ---------- */
.card, .sensor-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.2s ease;
}

.card:hover, .sensor-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.card-header {
    padding: 0.875rem 1rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.card-title {
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
}

.card-body {
    padding: 1rem;
}

.card-footer {
    padding: 0.75rem 1rem;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ---------- СВОЙСТВА ДАТЧИКОВ ---------- */
.sensor-property {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    gap: 0.5rem;
    flex-wrap: wrap;
}

.property-label {
    color: var(--text-secondary);
   font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.property-value {
    font-size: 0.85rem;
    font-weight: 500;
    word-break: break-word;
    text-align: right;
    color: var(--text-primary);
}

/* ---------- ЗНАЧЕНИЯ ---------- */
.value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.timestamp {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ---------- СТАТУСЫ ---------- */
.success, .ok {
    color: var(--success);
}

.warning {
    color: var(--warning);
}

.error, .critical {
    color: var(--error);
}

/* ---------- БЕЙДЖИ ---------- */
.badge, .history-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 500;
}

.history-yes {
    background: var(--success-bg);
    color: var(--success);
}

.history-no {
    background: var(--error-bg);
    color: var(--error);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info);
}

/* ---------- КНОПКИ ---------- */
button, .btn, input[type="submit"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

button:hover, .btn:hover, input[type="submit"]:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-danger {
    background: var(--error-bg);
    border-color: var(--error);
    color: var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: #fff;
}

.btn-sm {
    padding: 0.25rem 0.625rem;
    font-size: 0.7rem;
}

@media (max-width: 480px) {
    button, .btn {
        width: 100%;
    }
    .card-footer {
        flex-direction: column;
    }
}

/* ---------- ВКЛАДКИ ---------- */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
    flex-wrap: wrap;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.tab-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    color: #fff;
}

.tab-content {
    display: none;
    animation: fadeIn 0.25s ease;
}

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

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

/* ---------- ФОРМЫ ---------- */
.form-box {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 0.875rem;
}

label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input, select, textarea, datalist {
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.2);
}

input[type="checkbox"] {
    width: auto;
    margin-right: 0.5rem;
}

small, .help-text {
    display: block;
    color: var(--text-muted);
    font-size: 0.65rem;
    margin-top: 0.25rem;
}

/* ---------- КОМАНДЫ ---------- */
code, .command {
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    background: var(--bg-input);
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    color: var(--accent);
    word-break: break-all;
}

/* ---------- ПУСТОЕ СОСТОЯНИЕ ---------- */
.empty-state {
    text-align: center;
    padding: 2rem;
    background: var(--bg-panel);
    border-radius: 12px;
    color: var(--text-muted);
}

/* ---------- ЛОГИ ---------- */
.log-content {
    background: var(--bg-main);
    border-radius: 8px;
    font-family: monospace;
    font-size: 0.7rem;
    line-height: 1.5;
}

.log-line {
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--border-light);
    white-space: pre-wrap;
    word-break: break-word;
}

.log-line.error {
    color: var(--error);
    border-left: 3px solid var(--error);
    background: var(--error-bg);
}

.log-line.warning {
    color: var(--warning);
    border-left: 3px solid var(--warning);
    background: var(--warning-bg);
}

/* ---------- ФИЛЬТРЫ ---------- */
.filter-bar {
    background: var(--bg-panel);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.filter-btn {
    padding: 0.375rem 0.875rem;
    background: var(--bg-hover);
    border-radius: 20px;
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.filter-btn:hover, .filter-btn.active {
    background: var(--accent);
    color: #fff;
}

/* ---------- ХЕДЕР ЭНЕРГЕТИКИ (cottage_panel) ---------- */
.header-energy {
    border-radius: 2rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

body:not(.light) .header-energy {
    background: linear-gradient(135deg, #0d1f2e, #0a1520);
    border: 1px solid rgba(79, 158, 247, 0.2);
}

body.light .header-energy {
    background: linear-gradient(135deg, #e8f0fe, #d4e4fc);
    border: 1px solid rgba(79, 158, 247, 0.3);
}

.header-energy h1 {
    margin: 0 0 0.5rem 0;
}

.weather-mini {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.power-balance {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
}

.balance-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.75rem 1.5rem;
    border-radius: 1.5rem;
    flex: 1;
    min-width: 150px;
}

body.light .balance-item {
    background: rgba(0, 0, 0, 0.03);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.balance-icon {
    font-size: 2rem;
}

.balance-info h3 {
    font-size: 0.75rem;
    margin: 0;
    color: var(--text-secondary);
    font-weight: normal;
}

.balance-info .value {
    font-size: 1.75rem;
}

.badge-source {
    background: rgba(79, 158, 247, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    color: var(--accent);
}

.live-badge {
    background: #ff4444;
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@media (max-width: 768px) {
    .header-energy {
        padding: 1rem;
    }
    .power-balance {
        flex-direction: column;
    }
    .balance-item {
        width: 100%;
    }
    .badge-source {
        text-align: center;
        width: 100%;
    }
}

/* ---------- АКВАРИУМНЫЕ СТИЛИ ---------- */
.aqua-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.aqua-item {
    background: var(--bg-card-secondary);
    border-radius: 1rem;
    padding: 1rem;
}

.aq-title {
    font-weight: 700;
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.aq-row {
    display: flex;
    justify-content: space-between;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.8rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.led-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.3rem;
}

.led-green {
    background: #2dc96e;
    box-shadow: 0 0 3px #2dc96e;
}

.led-off {
    background: #555;
}

.badge-aq {
    padding: 0.2rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.7rem;
}

.badge-aq.ok {
    background: var(--success-bg);
    color: var(--success);
}

.badge-aq.warn {
    background: var(--warning-bg);
    color: var(--warning);
}

/* ---------- НАВИГАЦИЯ (links_panel) ---------- */
.nav-panel {
    margin-bottom: 1.5rem;
}

.nav-desktop {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.nav-left {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.nav-right {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.nav-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card-secondary);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    color: var(--text-primary);
    border: 1px solid var(--border);
    font-weight: 600;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 30px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid var(--border-light);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.nav-link:hover {
    transform: translateY(-2px);
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.nav-link.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.theme-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-card);
    padding: 0.25rem 0.75rem;
    border-radius: 40px;
    border: 1px solid var(--border);
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

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

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-input);
    transition: 0.3s;
    border-radius: 34px;
}

.theme-slider:before {
    position: absolute;
    content: "🌙";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 2px;
    background-color: var(--accent);
    transition: 0.3s;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

input:checked + .theme-slider:before {
    transform: translateX(26px);
    content: "☀️";
}

.nav-mobile {
    display: none;
}

.burger-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 40px;
    padding: 0.7rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-primary);
}

.burger-icon {
    font-size: 1.3rem;
}

.burger-arrow {
    transition: transform 0.3s ease;
}

.burger-arrow.open {
    transform: rotate(180deg);
}

.mobile-menu {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-panel);
    border-radius: 20px;
    border: 1px solid var(--border);
}

.mobile-menu.open {
    display: flex;
}

.mobile-menu .nav-link {
    justify-content: center;
    padding: 0.7rem;
}

.mobile-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .nav-desktop {
        display: none;
    }
    .nav-mobile {
        display: block;
    }
}

/* ---------- СКРОЛЛБАР ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-panel);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}
/* ========================================
   СТИЛИ ДЛЯ CRON ЛОГОВ (cron_logs.php)
   ======================================== */

/* Контейнер логов внутри карточки */
.log-content {
    max-height: 300px;
    overflow-y: auto;
    background: var(--bg-main);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 0.7rem;
    line-height: 1.4;
    margin: 0;
    padding: 0;
}

/* Стили для строк логов */
.log-line {
    padding: 0.3rem 0.75rem;
    border-bottom: 1px solid var(--border-light);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: monospace;
    font-size: 0.7rem;
}

.log-line.error {
    color: var(--error);
    border-left: 3px solid var(--error);
    background: var(--error-bg);
}

.log-line.warning {
    color: var(--warning);
    border-left: 3px solid var(--warning);
    background: var(--warning-bg);
}

.log-line:hover {
    background: var(--bg-hover);
}

/* Убираем лишние отступы у карточки */
.sensor-card .card-body {
    padding: 0;
}

/* Кнопки в карточке */
.sensor-card .card-footer {
    padding: 0.5rem 0.75rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Статус бар */
.status-bar {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background: var(--bg-panel);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    border: 1px solid var(--border);
    z-index: 100;
    font-family: monospace;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .log-content {
        max-height: 250px;
    }

    .log-line {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }

    .status-bar {
        bottom: 5px;
        right: 5px;
        font-size: 0.6rem;
    }
}

/* Стили для скроллбара внутри логов */
.log-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.log-content::-webkit-scrollbar-track {
    background: var(--bg-panel);
    border-radius: 3px;
}

.log-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.log-content::-webkit-scrollbar-thumb:hover {
    background: var(--accent);
}


/* ========================================
   ДОПОЛНИТЕЛЬНЫЕ СТИЛИ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ
   ======================================== */

/* Восстанавливаем отступы в карточках */
.sensor-card .card-body,
.card .card-body {
    padding: 1rem !important;
}

/* Для свойств датчиков */
.sensor-property {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Значение в карточке */
.sensor-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

/* Отступы для текста */
.sensor-card p,
.sensor-card div:not(.sensor-property) {
    margin-bottom: 0.25rem;
}

/* Восстанавливаем отступы в card-body на главной */
#tab-dashboard .sensor-card .card-body {
    padding: 1rem !important;
}

/* Для карточки статуса автоматизации */
#tab-dashboard .sensor-card .sensor-property {
    padding: 0.5rem 0;
}

/* Для карточки железа */
#tab-dashboard .sensor-card .sensor-timestamp {
    margin-top: 0.5rem;
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Убираем конфликт с пустыми стилями */
.card-body .empty-state {
    padding: 1rem;
    text-align: center;
}
