/* Цветовая схема */
:root {
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-color: #dee2e6;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.15);
    
    --color-up: #28a745;
    --color-down: #dc3545;
    --color-link: #0d6efd;
    --color-primary: #0d6efd;
    --color-danger: #dc3545;
}

/* Сброс стилей */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    /* Убеждаемся, что футер всегда виден */
    justify-content: flex-start;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    min-height: 0; /* Позволяет навигации сжиматься, чтобы футер был виден */
    overflow-y: auto; /* Прокрутка навигации, если элементов много */
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s;
}

.nav-item:hover {
    background-color: var(--bg-primary);
}

.nav-item.active {
    background-color: var(--bg-primary);
    border-right: 3px solid var(--color-primary);
    font-weight: 500;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto; /* Прижимаем футер к низу */
    flex-shrink: 0; /* Футер не сжимается */
    background-color: var(--bg-secondary); /* Убеждаемся, что фон виден */
}

.sidebar-footer .nav-item {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.75rem 0;
}

.sidebar-footer .logout-link {
    display: flex !important;
    align-items: center;
    color: var(--text-primary) !important;
    text-decoration: none !important;
    padding: 0.75rem 0 !important;
    margin-top: 0.75rem !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.user-info {
    padding: 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.user-email {
    font-family: monospace;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 2rem;
    max-width: 1400px;
}

/* Auth pages */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    background-color: var(--bg-secondary);
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 2rem;
    text-align: center;
}

.auth-footer {
    margin-top: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.auth-footer a {
    color: var(--color-link);
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background-color: #0b5ed7;
}

.btn-secondary {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-danger {
    background-color: var(--color-danger);
    color: white;
}

.btn-danger:hover {
    background-color: #bb2d3b;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
}

.stat-up {
    color: var(--color-up);
}

.stat-down {
    color: var(--color-down);
}

/* Sections */
.section {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background-color: var(--bg-primary);
}

.data-table th {
    padding: 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.data-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background-color: var(--bg-primary);
}

.data-table code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    background-color: var(--bg-primary);
    padding: 0.25rem 0.5rem;
    border-radius: 3px;
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-up {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--color-up);
}

.status-down {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--color-down);
}

.status-unknown {
    background-color: var(--bg-primary);
    color: var(--text-secondary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state a {
    color: var(--color-link);
    text-decoration: none;
}

.empty-state a:hover {
    text-decoration: underline;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-content form {
    padding: 1.5rem;
}

/* Messages */
.message {
    padding: 0.75rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.message-error {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--color-down);
    border: 1px solid rgba(220, 53, 69, 0.2);
}

.message-success {
    background-color: rgba(40, 167, 69, 0.1);
    color: var(--color-up);
    border: 1px solid rgba(40, 167, 69, 0.2);
}

/* Text utilities */
.text-muted {
    color: var(--text-secondary);
}

/* Кнопка гамбургер-меню (скрыта по умолчанию) */
.mobile-menu-toggle {
    display: none;
}

/* Кнопка закрытия в сайдбаре (скрыта по умолчанию) */
.sidebar-close {
    display: none;
}

/* Overlay для затемнения фона (скрыт по умолчанию) */
.sidebar-overlay {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-left: 200px;
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}

@media (max-width: 640px) {
    /* Кнопка гамбургер-меню */
    .mobile-menu-toggle {
        display: flex !important; /* Принудительно показываем на мобильных */
        position: fixed !important;
        top: 1rem !important;
        left: 1rem !important;
        z-index: 1001 !important;
        width: 44px !important;
        height: 44px !important;
        background-color: var(--bg-secondary) !important;
        border: 2px solid var(--border-color) !important;
        border-radius: 6px !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 5px !important;
        cursor: pointer !important;
        box-shadow: var(--shadow-lg) !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .mobile-menu-toggle span {
        width: 22px !important;
        height: 3px !important;
        background-color: var(--text-primary) !important;
        border-radius: 2px !important;
        transition: all 0.3s;
        display: block !important;
        flex-shrink: 0 !important;
    }
    
    .mobile-menu-toggle:hover {
        background-color: var(--bg-primary);
    }
    
    /* Overlay для затемнения фона */
    .sidebar-overlay {
        display: block !important; /* Показываем overlay на мобильных */
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s, visibility 0.3s;
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Sidebar на мобильных - обрезан по высоте на 50% и центрирован вертикально */
    .sidebar {
        transform: translateX(-100%) translateY(-50%); /* Скрываем влево и центрируем вертикально */
        transition: transform 0.3s ease-in-out;
        z-index: 1000;
        width: 260px; /* Ширина остается прежней */
        height: 50vh; /* 50% высоты экрана */
        max-height: 400px; /* Максимальная высота для больших экранов */
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        left: 0; /* Остается слева */
        top: 50%; /* Центрируем вертикально */
        position: fixed;
    }
    
    .sidebar.open {
        transform: translateX(0) translateY(-50%); /* При открытии показываем, сохраняя вертикальное центрирование */
    }
    
    /* Убеждаемся, что футер и кнопка выхода видны на мобильных */
    .sidebar-footer {
        padding: 1rem 1.5rem !important;
        border-top: 1px solid var(--border-color) !important;
        margin-top: auto !important;
        display: flex !important;
        flex-direction: column !important;
        flex-shrink: 0 !important; /* Футер не сжимается */
        background-color: var(--bg-secondary) !important;
        position: relative !important;
        z-index: 10 !important; /* Футер поверх навигации */
    }
    
    .sidebar-footer .user-info {
        margin-bottom: 0.5rem !important;
        display: block !important;
    }
    
    .sidebar-footer .nav-item,
    .sidebar-footer .logout-link {
        display: flex !important;
        align-items: center !important;
        padding: 0.75rem 0 !important;
        margin: 0 !important;
        margin-top: 0.75rem !important;
        width: 100% !important;
        color: var(--text-primary) !important;
        text-decoration: none !important;
        font-size: 0.875rem !important;
        opacity: 1 !important;
        visibility: visible !important;
        background-color: transparent !important;
    }
    
    .sidebar-footer .nav-item:hover,
    .sidebar-footer .logout-link:hover {
        background-color: var(--bg-primary) !important;
    }
    
    /* Навигация не должна занимать всё пространство */
    .sidebar-nav {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow-y: auto !important;
    }
    
    /* Кнопка закрытия в сайдбаре */
    .sidebar-header {
        position: relative;
    }
    
    .sidebar-close {
        display: block !important; /* Принудительно показываем на мобильных */
        position: absolute;
        top: 1rem;
        right: 1rem;
        width: 32px;
        height: 32px;
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-primary);
        cursor: pointer;
        line-height: 1;
        padding: 0;
    }
    
    .sidebar-close:hover {
        color: var(--text-secondary);
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 5.5rem; /* Отступ для кнопки меню */
        width: 100%;
        max-width: 100%;
    }
    
    /* Адаптивные стили для секций на мобильных */
    .section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .page-header {
        margin-bottom: 1rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr !important; /* Одна колонка на мобильных */
        gap: 1rem !important;
        margin-bottom: 1rem !important;
    }
    
    .stat-card {
        padding: 1rem !important;
    }
    
    .stat-value {
        font-size: 1.5rem !important; /* Уменьшаем размер на мобильных */
    }
    
    /* Адаптивные таблицы */
    .table-container {
        -webkit-overflow-scrolling: touch;
        margin: 0 -1rem; /* Расширяем таблицу на всю ширину с отрицательными отступами */
        padding: 0 1rem;
    }
    
    .data-table {
        font-size: 0.8rem !important;
        min-width: 100%;
    }
    
    .data-table th,
    .data-table td {
        padding: 0.5rem 0.25rem !important;
        white-space: nowrap;
    }
    
    .data-table th:first-child,
    .data-table td:first-child {
        padding-left: 0.5rem;
    }
    
    .data-table th:last-child,
    .data-table td:last-child {
        padding-right: 0.5rem;
    }
}

/* Landing page styles */
.landing-container {
    min-height: 100vh;
    background-color: var(--bg-primary);
}

.landing-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
}

.landing-nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.landing-logo {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.landing-nav-buttons {
    display: flex;
    gap: 0.75rem;
}

.landing-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 3rem 2rem;
}

.landing-hero {
    text-align: center;
    margin-bottom: 3rem;
}

.landing-hero h2 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.landing-description {
    font-size: 1.125rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.8;
}

.landing-stats {
    margin-bottom: 3rem;
}

.landing-stats h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    text-align: center;
    color: var(--text-primary);
}

.landing-stats .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.landing-stats .stat-card {
    text-align: center;
}

.landing-stats .stat-value {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.landing-stats .stat-label {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-degraded {
    color: #ffc107;
}

.stat-uptime {
    color: var(--color-up);
}

.landing-info {
    background-color: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-top: 3rem;
}

.landing-note {
    color: var(--text-secondary);
    line-height: 1.8;
}

.landing-note strong {
    color: var(--text-primary);
}

.message-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #856404;
    border: 1px solid rgba(255, 193, 7, 0.2);
}

