/* ============================================================
   Портал учёта проживающих v2.0 — Общие стили
   ============================================================ */

/* --- Сброс и базовые --- */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
}

/* --- Страница входа --- */
body.login-page {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}
.login-container {
    background: white;
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}
.logo {
    text-align: center;
    margin-bottom: 30px;
}
.logo h1 {
    color: #1e3c72;
    font-size: 28px;
    font-weight: 600;
}
.logo p {
    color: #666;
    font-size: 14px;
    margin-top: 5px;
}
.login-form .form-group {
    margin-bottom: 20px;
}
.login-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}
.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(30,60,114,0.3);
}
.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}
.login-info {
    margin-top: 20px;
    text-align: center;
    color: #666;
    font-size: 12px;
}

/* --- Навигация --- */
.navbar {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.nav-brand {
    font-size: 1.3rem;
    font-weight: 600;
}
.nav-brand small {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-left: 10px;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.user-info {
    text-align: right;
}
.user-name {
    font-weight: 600;
}
.user-role {
    font-size: 0.8rem;
    opacity: 0.8;
}
.logout-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}
.logout-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* --- Контейнер --- */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* --- Вкладки --- */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    background: white;
    padding: 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    flex-wrap: wrap;
}
.tab {
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border: none;
    background: #f8f9fa;
    font-size: 0.95rem;
    color: #495057;
    border-radius: 8px;
    transition: all 0.3s;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}
.tab:hover {
    background: #e9ecef;
}
.tab.active {
    background: #1e3c72;
    color: white;
}

/* --- Контент --- */
.page-content {
    display: block;
}

/* --- Карточки --- */
.card {
    background: white;
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}
.card-header h2 {
    color: #1e3c72;
    font-weight: 600;
}

/* --- Кнопки --- */
.btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}
.btn-primary {
    background: #1e3c72;
    color: white;
}
.btn-primary:hover {
    background: #2a5298;
    transform: translateY(-2px);
}
.btn-success {
    background: #28a745;
    color: white;
}
.btn-success:hover {
    background: #34ce57;
}
.btn-info {
    background: #17a2b8;
    color: white;
}
.btn-info:hover {
    background: #31b8d0;
}
.btn-danger {
    background: #dc3545;
    color: white;
}
.btn-warning {
    background: #ffc107;
    color: #333;
}
.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* --- Плитки квартир --- */
.apartments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.apartment-card {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s;
    cursor: pointer;
    border: 2px solid transparent;
}
.apartment-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border-color: #1e3c72;
}
.apartment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.apartment-number {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1e3c72;
}
.apartment-floor {
    font-size: 0.8rem;
    color: #6c757d;
    background: #f8f9fa;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
}
.progress-bar-container {
    background: #e9ecef;
    border-radius: 10px;
    height: 12px;
    margin: 1rem 0;
    overflow: hidden;
}
.progress-bar {
    background: #28a745;
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s;
}
.progress-bar.warning {
    background: #ffc107;
}
.progress-bar.danger {
    background: #dc3545;
}
.apartment-stats {
    display: flex;
    justify-content: space-between;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}
.apartment-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* --- Модальные окна --- */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal.active {
    display: flex;
}
.modal-content {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.modal-header h3 {
    color: #1e3c72;
}
.close {
    font-size: 1.5rem;
    cursor: pointer;
    color: #adb5bd;
}
.close:hover {
    color: #dc3545;
}

/* --- Формы --- */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #495057;
}
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.95rem;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: #1e3c72;
}

/* --- Таблицы --- */
.table-container {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th {
    background: #f8f9fa;
    color: #1e3c72;
    font-weight: 600;
    padding: 1rem;
    text-align: left;
    border-bottom: 2px solid #1e3c72;
}
td {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
}
tr:hover {
    background: #f8f9fa;
}

/* --- Фильтры --- */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 12px;
}
.filter-group {
    flex: 1;
    min-width: 150px;
}
.filter-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    font-size: 0.85rem;
}
.filter-group input, .filter-group select {
    width: 100%;
    padding: 0.6rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
}

/* --- Статистика --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1e3c72;
}
.stat-label {
    color: #6c757d;
    margin-top: 0.5rem;
}

/* --- Бейджи статуса --- */
.status-badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-active {
    background: #d4edda;
    color: #155724;
}
.status-soon {
    background: #fff3cd;
    color: #856404;
}
.status-overdue {
    background: #f8d7da;
    color: #721c24;
}
.status-checked-out {
    background: #e2e3e5;
    color: #383d41;
}

/* --- Корпус-фильтр --- */
.building-filter {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.building-btn {
    padding: 0.5rem 1rem;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}
.building-btn.active {
    background: #1e3c72;
    color: white;
    border-color: #1e3c72;
}

/* --- Разделитель корпусов --- */
.building-divider {
    grid-column: 1 / -1;
    padding: 1rem 0 0.5rem;
    margin-top: 1rem;
    border-top: 3px solid #1e3c72;
}
.building-divider h3 {
    color: #1e3c72;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0;
    padding-left: 0.5rem;
}
.building-divider:first-child {
    border-top: none;
    margin-top: 0;
    padding-top: 0;
}

/* --- Список жильцов в квартире --- */
.resident-list {
    margin-top: 1rem;
}
.resident-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem;
    border-bottom: 1px solid #e9ecef;
}
.resident-item:last-child {
    border-bottom: none;
}
.resident-info {
    flex: 1;
}
.resident-name {
    font-weight: 600;
}
.resident-dates {
    font-size: 0.8rem;
    color: #6c757d;
}

/* --- Уведомления --- */
.alert-list {
    background: #fff3cd;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.alert-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid #ffeeba;
}
.alert-item:last-child {
    border-bottom: none;
}

/* --- Адаптивность --- */
@media (max-width: 768px) {
    /* Шапка — компактная на мобильных */
    .navbar {
        flex-direction: row;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }
    .nav-brand {
        font-size: 0.95rem;
        font-weight: 700;
    }
    .nav-brand small {
        display: none; /* Скрываем адрес на мобильных */
    }
    .nav-user {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
    .user-info {
        text-align: right;
    }
    .user-name {
        font-size: 0.8rem;
        font-weight: 600;
    }
    .user-role {
        font-size: 0.65rem;
        opacity: 0.7;
        display: none; /* Скрываем роль на мобильных */
    }
    .logout-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.85rem;
    }

    /* Вкладки — горизонтальная прокрутка */
    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.5rem 0.75rem;
        gap: 0.4rem;
        margin-bottom: 1rem;
    }
    .tabs::-webkit-scrollbar {
        height: 0;
    }
    .tab {
        white-space: nowrap;
        font-size: 0.85rem;
        padding: 0.5rem 0.8rem;
        flex-shrink: 0;
    }

    /* Карточки */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    /* Статистика — 2 колонки */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    .stat-card {
        padding: 1rem;
    }
    .stat-value {
        font-size: 1.8rem;
    }

    /* Таблицы */
    .table-container {
        overflow-x: auto;
    }

    /* На очень маленьких экранах — карточки вместо таблицы */
    table.responsive-card {
        display: block;
    }
    table.responsive-card thead {
        display: none;
    }
    table.responsive-card tbody {
        display: block;
    }
    table.responsive-card tbody tr {
        display: block;
        background: white;
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 0.75rem;
        border: 1px solid #e9ecef;
        box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    }
    table.responsive-card tbody tr:hover {
        background: #f8f9fa;
    }
    table.responsive-card tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.4rem 0;
        border-bottom: 1px solid #f0f0f0;
        font-size: 0.85rem;
    }
    table.responsive-card tbody td:last-child {
        border-bottom: none;
        padding-top: 0.75rem;
        justify-content: flex-start;
        gap: 0.5rem;
    }
    table.responsive-card tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #1e3c72;
        font-size: 0.8rem;
        flex-shrink: 0;
        min-width: 100px;
    }

    /* Фильтры */
    .filter-bar {
        flex-direction: column;
    }
    .apartments-grid {
        grid-template-columns: 1fr;
    }
    .container {
        margin: 1rem auto;
        padding: 0 0.5rem;
    }
}
