/* ═══════════════════════════════════════════════════════════════════════════════
   ОБЩИЕ КОМПОНЕНТЫ
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ───────────────────────────────────────────────────────────────────────────────
   КОНТЕЙНЕР
   ─────────────────────────────────────────────────────────────────────────────── */

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px 20px;
    flex: 1;
    width: 100%;
    min-width: 0;
}

/* ───────────────────────────────────────────────────────────────────────────────
   КНОПКИ
   ─────────────────────────────────────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-xl);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    box-shadow: var(--shadow);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:hover:not(:disabled) {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
}

.btn-secondary.btn-active {
    background: #1976D2;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #b91c1c;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
    display: block;
}

/* ───────────────────────────────────────────────────────────────────────────────
   ФОРМЫ
   ─────────────────────────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 20px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: var(--transition);
    background: var(--bg-primary);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ───────────────────────────────────────────────────────────────────────────────
   ТАБЛИЦЫ
   ─────────────────────────────────────────────────────────────────────────────── */

.table-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow-x: auto;
    overflow-y: visible;
    padding: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    position: relative;
}

.data-table thead {
    background: var(--bg-secondary);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}

.data-table .loading-cell,
.data-table .empty-cell,
.data-table .error-cell {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.data-table .error-cell {
    color: var(--danger-color);
}

/* ───────────────────────────────────────────────────────────────────────────────
   МОДАЛЬНЫЕ ОКНА
   ─────────────────────────────────────────────────────────────────────────────── */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

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

/* ───────────────────────────────────────────────────────────────────────────────
   BADGES И СТАТУСЫ
   ─────────────────────────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-admin {
    background: #fef3c7;
    color: #92400e;
}

.badge-employee {
    background: #dbeafe;
    color: #1e40af;
}

.badge-client {
    background: #dcfce7;
    color: #166534;
}

.badge-partner {
    background: #f3e8ff;
    color: #6b21a8;
}

.status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-inactive {
    background: #fee2e2;
    color: #991b1b;
}

/* ───────────────────────────────────────────────────────────────────────────────
   СООБЩЕНИЯ
   ─────────────────────────────────────────────────────────────────────────────── */

.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-top: 16px;
    font-size: 13px;
    border-left: 4px solid var(--danger-color);
}

/* ───────────────────────────────────────────────────────────────────────────────
   ХЕЛПЕРЫ
   ─────────────────────────────────────────────────────────────────────────────── */

.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
    opacity: 0.7;
}

.btn-icon:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* ───────────────────────────────────────────────────────────────────────────────
   ПАГИНАЦИЯ
   ─────────────────────────────────────────────────────────────────────────────── */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination-button {
    min-width: 40px;
    height: 40px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pagination-button:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.pagination-button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 600;
}

.pagination-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-prev,
.pagination-next {
    font-size: 16px;
    font-weight: 600;
}

.pagination-ellipsis {
    padding: 0 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 13px;
    margin-left: 12px;
    white-space: nowrap;
}

/* ───────────────────────────────────────────────────────────────────────────────
   МОБИЛЬНЫЕ КАРТОЧКИ (преобразование таблиц)
   ─────────────────────────────────────────────────────────────────────────────── */

/* По умолчанию карточки скрыты (показываем таблицу) */
.card-list {
    display: none;
}

@media (max-width: 768px) {
    /* Скрываем таблицу на мобильных */
    .data-table {
        display: none;
    }

    /* Показываем карточки на мобильных */
    .card-list {
        display: block;
        margin-top: 16px;
    }

    /* Карточка */
    .card {
        background: var(--bg-primary);
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow);
        padding: 16px;
        margin-bottom: 12px;
        border-left: 4px solid var(--primary-color);
    }

    /* Поле карточки */
    .card-field {
        justify-content: space-between;
    }

    .card-field:last-child {
        border-bottom: none;
    }

    /* Метка поля */
    .card-label {
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 12px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        min-width: 100px;
    }

    /* Значение поля */
    .card-value {
        flex: 1;
        text-align: right;
        font-size: 14px;
        color: var(--text-primary);
    }

    /* Действия в карточке */
    .card-actions {
        display: flex;
        gap: 8px;
        justify-content: center;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 2px solid var(--border-color);
    }

    /* Аватар в карточке */
    .card-avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        object-fit: cover;
    }

    /* Компактные кнопки для мобильных */
    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    /* Заголовок страницы */
    .page-header {
        flex-direction: column;
        gap: 12px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    /* Кнопки в заголовке */
    .header-buttons {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .header-buttons .btn {
        flex: 1;
        min-width: 100px;
        font-size: 12px;
        padding: 8px 12px;
    }

    /* Фильтры */
    .filters-panel {
        padding: 12px;
    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    /* Пагинация */
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }

    .pagination-button {
        min-width: 36px;
        height: 36px;
        font-size: 12px;
        padding: 0;
    }

    .pagination-info {
        width: 100%;
        text-align: center;
        margin-bottom: 8px;
        order: -1;
    }

    /* Модальные окна */
    .modal-content {
        margin: 10px;
        max-width: calc(100% - 20px);
        max-height: calc(100vh - 20px);
        overflow-y: auto;
    }

    /* Формы */
    .form-group {
        margin-bottom: 12px;
    }

    .form-group label {
        font-size: 13px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Предотвращает zoom на iOS */
    }

    /* Контейнер */
    .container {
        padding: 12px;
    }

    /* Хлебные крошки */
    .breadcrumbs {
        font-size: 12px;
        flex-wrap: wrap;
    }
}

