/* Основные стили для светлой и тёмной темы */
body.light {
    background-color: white;
    color: black;
}
body.dark {
    background-color: #222;
    color: #eee;
}

/* Центрирование заголовков */
h1 {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

/* Стили навигационного меню (центрированное) */
nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}
body.dark nav {
    background-color: #333;
    border-bottom-color: #555;
}
nav a {
    text-decoration: none;
    color: #007bff;
    font-weight: bold;
    font-size: 16px;
}
nav a:hover {
    text-decoration: underline;
    color: #0056b3;
}
body.dark nav a {
    color: #66b0ff;
}
body.dark nav a:hover {
    color: #99c6ff;
}

/* Сетка сервисов (7 колонок) */
.service-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 15px;
    padding: 20px;
}
@media (max-width: 1200px) {
    .service-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (max-width: 800px) {
    .service-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 500px) {
    .service-grid {
        grid-template-columns: 1fr;
    }
}

/* Карточка сервиса */
.service-card {
    border: 2px solid;
    padding: 15px;
    border-radius: 8px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
body.dark .service-card {
    background-color: #333;
    box-shadow: 0 2px 5px rgba(255,255,255,0.1);
}
.service-card.online {
    border-color: green;
}
.service-card.offline {
    border-color: red;
}
.service-card h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
    color: inherit;
}
.service-card.online h3 {
    color: green;
}
.service-card.offline h3 {
    color: red;
}

/* Тёмная тема для заголовков */
body.dark .service-card.online h3 {
    color: #90EE90; /* светло-зелёный для тёмной темы */
}
body.dark .service-card.offline h3 {
    color: #ff8080; /* светло-красный для тёмной темы */
}
.service-card p {
    margin: 5px 0;
    font-size: 14px;
}

/* Контейнер для действий с сервисом */
.service-actions {
    margin-top: 12px;
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    align-items: center;
}

/* Единые кнопки действий */
.action-btn,
a.action-btn,
button.action-btn {
    display: inline-block;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    line-height: 1.5;
}
.action-btn:hover,
a.action-btn:hover,
button.action-btn:hover {
    background-color: #0056b3;
    color: white;
    text-decoration: none;
}

/* Тёмная тема для кнопок действий */
body.dark .action-btn,
body.dark a.action-btn,
body.dark button.action-btn {
    background-color: #1e7e34;
}
body.dark .action-btn:hover,
body.dark a.action-btn:hover,
body.dark button.action-btn:hover {
    background-color: #155d27;
}

/* Форма удаления (inline) */
.delete-form {
    display: inline;
    margin: 0;
    padding: 0;
}

/* Стили для форм */
form, .service-form {
    max-width: 500px;
    margin: 30px auto;
    padding: 25px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
body.dark form,
body.dark .service-form {
    background: #333;
    box-shadow: 0 4px 8px rgba(255,255,255,0.1);
}
label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}
input, select {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
}
body.dark input,
body.dark select {
    background: #555;
    color: #eee;
    border-color: #777;
}
button {
    background: #28a745;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    font-size: 16px;
    font-weight: bold;
}
button:hover {
    background: #218838;
}
body.dark button {
    background: #1e7e34;
}
body.dark button:hover {
    background: #155d27;
}

/* Сообщения об ошибках */
.error-message {
    color: red;
    text-align: center;
    margin-bottom: 15px;
    font-weight: bold;
}
body.dark .error-message {
    color: #ff8080;
}

/* Кнопка переключения темы - под меню, по центру */
.theme-toggle {
    display: block;
    margin: 30px auto 20px auto;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 30px;
    padding: 10px 30px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    width: fit-content;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    text-decoration: none;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
    
    /* Убираем всё, что могло остаться от fixed */
    position: static;
    bottom: auto;
    right: auto;
    z-index: auto;
}

.theme-toggle:hover {
    background: #0056b3;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transform: translateY(-1px);
}

body.dark .theme-toggle {
    background: #ffc107;
    color: #222;
    box-shadow: 0 2px 8px rgba(255,255,255,0.1);
}
body.dark .theme-toggle:hover {
    background: #e0a800;
    box-shadow: 0 4px 12px rgba(255,255,255,0.15);
}

/* Стили для таблицы истории */
.history-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
body.dark .history-table {
    background-color: #333;
    color: #eee;
}
.history-table th,
.history-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}
body.dark .history-table th,
body.dark .history-table td {
    border-bottom-color: #555;
}
.history-table th {
    background-color: #f8f9fa;
    font-weight: bold;
}
body.dark .history-table th {
    background-color: #444;
}
.online-row {
    background-color: #d4edda;
}
body.dark .online-row {
    background-color: #1e3b2a;
}
.offline-row {
    background-color: #f8d7da;
}
body.dark .offline-row {
    background-color: #4a2c2c;
}
/* Контейнеры для графиков */
canvas {
    max-width: 100%;
    height: auto !important;
    background-color: #fff;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
body.dark canvas {
    background-color: #333;
    box-shadow: 0 2px 5px rgba(255,255,255,0.1);
}
/* Статистика ICMP */
#icmp-stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 15px;
}
#icmp-stats p {
    margin: 0;
    padding: 10px 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-size: 16px;
}
body.dark #icmp-stats p {
    background: #444;
    color: #eee;
}
#icmp-stats span {
    font-weight: bold;
    color: #007bff;
}
body.dark #icmp-stats span {
    color: #66b0ff;
}
/* Заголовки разделов */
.section-title {
    margin: 30px 0 15px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #dee2e6;
    font-size: 24px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}
body.dark .section-title {
    color: #eee;
    border-bottom-color: #555;
}
/* Стили для сворачиваемых разделов */
.section-container {
    margin-bottom: 20px;
}
.section-header {
    cursor: pointer;
    user-select: none;
    padding: 5px 0;
}
.section-header:hover {
    opacity: 0.8;
}
.collapse-icon {
    display: inline-block;
    width: 24px;
    font-size: 16px;
    color: #007bff;
    transition: transform 0.2s;
}

body.dark .collapse-icon {
    color: #66b0ff;
}

.service-count {
    font-size: 16px;
    color: #6c757d;
    margin-left: 10px;
}

body.dark .service-count {
    color: #aaa;
}

/* Анимация при сворачивании/разворачивании */
.service-grid {
    transition: opacity 0.3s ease;
}

.service-grid[style*="display: none"] {
    opacity: 0;
}
/* Стили для админ-панели */
.user-info {
    text-align: right;
    margin-bottom: 20px;
    padding: 10px 15px;
    background: #e9ecef;
    border-radius: 8px;
    font-size: 14px;
}
body.dark .user-info {
    background: #333;
    color: #eee;
}

.section {
    margin: 30px 0;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
body.dark .section {
    background: #333;
    box-shadow: 0 2px 5px rgba(255,255,255,0.1);
}

.section h2 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 20px;
    color: #333;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 10px;
}
body.dark .section h2 {
    color: #eee;
    border-bottom-color: #555;
}

.form-group {
    margin: 15px 0;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #495057;
}
body.dark .form-group label {
    color: #aaa;
}

.form-group input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
}
body.dark .form-group input[type="text"] {
    background: #555;
    color: #eee;
    border-color: #777;
}

.ip-list {
    margin: 10px 0;
}

.ip-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}
body.dark .ip-item {
    background: #444;
    border-color: #555;
}

.ip-address {
    font-family: monospace;
    font-size: 15px;
    color: #495057;
}
body.dark .ip-address {
    color: #ddd;
}

.cidr-list {
    list-style: none;
    padding: 0;
    margin: 10px 0;
}

.cidr-list li {
    padding: 8px 0;
    font-family: monospace;
    border-bottom: 1px dashed #dee2e6;
}
body.dark .cidr-list li {
    border-bottom-color: #555;
}

.empty-message {
    color: #6c757d;
    font-style: italic;
    padding: 15px;
    text-align: center;
}
body.dark .empty-message {
    color: #aaa;
}

/* Стили для статистики */
.stats-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
}
body.dark .stats-card {
    background: #333;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #e9ecef;
}
body.dark .stat-item {
    border-bottom-color: #555;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-weight: bold;
    color: #495057;
    font-size: 15px;
}
body.dark .stat-label {
    color: #aaa;
}

.stat-value {
    font-family: monospace;
    font-size: 15px;
    color: #007bff;
}
body.dark .stat-value {
    color: #66b0ff;
}

.stat-value.blocked {
    color: #dc3545;
    font-weight: bold;
}

.stat-value.whitelisted {
    color: #28a745;
    font-weight: bold;
}

/* Бейджи для статистики */
.badge-success {
    background: #28a745;
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.badge-warning {
    background: #ffc107;
    color: black;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.badge-danger {
    background: #dc3545;
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}
/* Стили для ссылки переключения темы */
.theme-link {
    cursor: pointer;
    user-select: none;
}

.theme-link:hover {
    opacity: 0.8;
}

/* Можно добавить иконки через псевдоэлементы */
.theme-link::before {
    content: "🌓 ";
    font-size: 16px;
}

body.dark .theme-link::before {
    content: "☀️ ";
}

/* Временные стили для отладки */
.service-card.online {
    border-color: green;
    background-color: #f0fff0;  /* светло-зеленый фон */
}
.service-card.offline {
    border-color: red;
    background-color: #fff0f0;  /* светло-красный фон */
}
/* Status colors */
.status-online {
    color: green;
    font-weight: bold;
}

.status-offline {
    color: red;
    font-weight: bold;
}

/* Dark theme support */
body.dark .status-online {
    color: #90EE90;
}

body.dark .status-offline {
    color: #ff8080;
}
