/* ============================================================
   📘 m-style.css — Metrik UI Components
   Версия: 2.0 | Дата: 2026-08-26
   Основан на style_guide.md
   ============================================================ */

/* ===== 1. ПЕРЕМЕННЫЕ ===== */
:root {
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --primary-light: #818cf8;
    --secondary: #2d3748;
    --success: #48bb78;
    --success-dark: #38a169;
    --warning: #f6ad55;
    --danger: #f56565;
    --danger-dark: #dc2626;
    --info: #4299e1;
    --light-bg: #f7fafc;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* ===== 2. КОНТЕЙНЕРЫ ===== */
.m-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.m-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 24px 28px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.m-card-light {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* ===== 3. КНОПКИ ===== */
.m-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
}

.m-btn:hover {
    transform: translateY(-2px);
}

.m-btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.m-btn-primary:hover {
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
    color: white;
}

.m-btn-success {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    color: white;
    box-shadow: 0 4px 15px rgba(72, 187, 120, 0.3);
}

.m-btn-success:hover {
    box-shadow: 0 8px 25px rgba(72, 187, 120, 0.4);
    color: white;
}

.m-btn-outline {
    background: white;
    color: var(--text-secondary);
    border-color: var(--border);
}

.m-btn-outline:hover {
    background: var(--light-bg);
    border-color: #cbd5e0;
}

.m-btn-danger {
    background: white;
    color: var(--danger);
    border-color: #fecaca;
}

.m-btn-danger:hover {
    background: #fff5f5;
    border-color: var(--danger);
}

.m-btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.m-btn-lg {
    padding: 14px 32px;
    font-size: 1.05rem;
}

.m-btn-block {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* ===== 4. ВКЛАДКИ ===== */
.m-tabs {
    display: flex;
    gap: 6px;
    background: var(--light-bg);
    padding: 4px;
    border-radius: 40px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.m-tab {
    padding: 8px 20px;
    border-radius: 40px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
}

.m-tab:hover {
    background: #edf2f7;
    color: var(--text-primary);
}

.m-tab.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.m-tab .m-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.05rem 0.5rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
}

.m-tab.active .m-badge {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== 5. БЕЙДЖИ ===== */
.m-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.7rem;
    white-space: nowrap;
}

.m-badge-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #c8e6c9;
}

.m-badge-danger {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.m-badge-warning {
    background: #fff3e0;
    color: #e65100;
    border: 1px solid #ffe0b2;
}

.m-badge-info {
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

.m-badge-secondary {
    background: #e0e0e0;
    color: #424242;
    border: 1px solid #bdbdbd;
}

/* ===== 6. СТАТИСТИКА ===== */
.m-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.m-stat {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.2s;
}

.m-stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.m-stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.m-stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--secondary);
    line-height: 1.2;
}

.m-stat-label {
    color: #718096;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ===== 7. ФИЛЬТРЫ ===== */
.m-filters {
    background: white;
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.m-filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

.m-filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.m-filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.m-filter-group input,
.m-filter-group select {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: all 0.2s;
    background: white;
    width: 100%;
}

.m-filter-group input:focus,
.m-filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.m-filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* ===== 8. ТАБЛИЦЫ ===== */
.m-table-wrap {
    background: white;
    border-radius: var(--radius-lg);
    overflow-x: auto;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.m-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    min-width: 700px;
}

.m-table th {
    padding: 12px 14px;
    background: #f8fafc;
    font-weight: 600;
    color: #4a5568;
    border-bottom: 2px solid var(--border);
    text-align: left;
}

.m-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.m-table tbody tr:hover {
    background: #f7fafc;
}

.m-table-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* ===== 9. ФОРМЫ ===== */
.m-form-group {
    margin-bottom: 16px;
}

.m-form-group label {
    display: block;
    font-weight: 600;
    color: var(--secondary);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.m-form-group label .m-required {
    color: var(--danger);
    margin-left: 2px;
}

.m-form-group input,
.m-form-group select,
.m-form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    transition: all 0.2s;
    background: white;
    font-family: inherit;
}

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

.m-form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.m-form-group .m-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: flex;
    align-items: flex-start;
    gap: 4px;
}

.m-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.m-form-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.m-form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.m-section-title {
    font-size: 1.05rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--secondary);
    font-weight: 700;
}

.m-section-title i {
    color: var(--primary);
}

/* ===== 10. TOGGLE-SWITCH ===== */
.m-toggle-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.m-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}

.m-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.m-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.m-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.m-toggle input:checked + .m-toggle-slider {
    background-color: var(--primary);
}

.m-toggle input:checked + .m-toggle-slider:before {
    transform: translateX(22px);
}

.m-toggle-label {
    font-weight: 600;
    color: var(--secondary);
    font-size: 0.95rem;
    cursor: pointer;
}

.m-toggle-hidden {
    display: none;
}

/* ===== 11. МОДАЛКИ ===== */
.m-modal-overlay {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.m-modal {
    background: white;
    border-radius: var(--radius-xl);
    padding: 30px;
    width: 540px;
    max-width: 92%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: mModalSlideIn 0.3s ease;
}

@keyframes mModalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.m-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.m-modal-header h2 {
    margin: 0;
    color: var(--secondary);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.m-modal-header h2 i {
    color: var(--primary);
}

.m-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #a0aec0;
    transition: color 0.2s;
    padding: 0 8px;
}

.m-modal-close:hover {
    color: #4a5568;
}

.m-modal-footer {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ===== 12. TOAST ===== */
.m-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--secondary);
    color: white;
    padding: 14px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 10001;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 48px);
    animation: mToastSlideIn 0.3s ease;
}

.m-toast-success {
    background: var(--success);
}

.m-toast-error {
    background: var(--danger);
}

.m-toast-info {
    background: var(--primary);
}

@keyframes mToastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== 13. ПАГИНАЦИЯ ===== */
.m-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.m-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.m-page-link:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.m-page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    cursor: default;
}

.m-page-link.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.m-pagination-info {
    text-align: center;
    margin-top: 12px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== 14. АДАПТИВНОСТЬ ===== */
@media (max-width: 992px) {
    .m-form-row {
        grid-template-columns: 1fr;
    }

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

    .m-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .m-container {
        padding: 12px;
    }

    .m-card {
        padding: 18px 16px;
    }

    .m-card-light {
        padding: 16px;
    }

    .m-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        border-radius: var(--radius);
        gap: 4px;
    }

    .m-tab {
        white-space: nowrap;
        padding: 6px 14px;
        font-size: 0.78rem;
        flex: 1;
        justify-content: center;
    }

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

    .m-stats {
        grid-template-columns: 1fr 1fr;
    }

    .m-modal {
        padding: 20px;
        width: 100%;
        max-width: 100%;
        border-radius: var(--radius-lg);
        margin: 12px;
    }

    .m-btn {
        font-size: 0.85rem;
        padding: 8px 16px;
    }

    .m-btn-block {
        width: 100%;
        justify-content: center;
    }

    .m-pagination {
        gap: 4px;
    }

    .m-page-link {
        min-width: 34px;
        height: 34px;
        font-size: 0.8rem;
        padding: 0 8px;
    }
}

@media (max-width: 480px) {
    .m-stats {
        grid-template-columns: 1fr;
    }

    .m-stat {
        padding: 12px 14px;
    }

    .m-stat-value {
        font-size: 1.3rem;
    }

    .m-tab {
        font-size: 0.7rem;
        padding: 4px 10px;
    }

    .m-table-wrap {
        border-radius: var(--radius);
    }

    .m-table th,
    .m-table td {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
}

/* ===== 15. УТИЛИТЫ ===== */
.m-text-center {
    text-align: center;
}

.m-text-right {
    text-align: right;
}

.m-flex {
    display: flex;
}

.m-flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.m-flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.m-gap-2 {
    gap: 8px;
}

.m-gap-3 {
    gap: 12px;
}

.m-gap-4 {
    gap: 16px;
}

.m-mt-2 {
    margin-top: 8px;
}

.m-mt-3 {
    margin-top: 12px;
}

.m-mt-4 {
    margin-top: 16px;
}

.m-mb-2 {
    margin-bottom: 8px;
}

.m-mb-3 {
    margin-bottom: 12px;
}

.m-mb-4 {
    margin-bottom: 16px;
}

.m-mb-6 {
    margin-bottom: 24px;
}

.m-text-muted {
    color: var(--text-muted);
}

.m-text-success {
    color: var(--success);
}

.m-text-danger {
    color: var(--danger);
}

.m-text-primary {
    color: var(--primary);
}

.m-hidden {
    display: none !important;
}

.m-visible-mobile {
    display: none;
}

@media (max-width: 768px) {
    .m-visible-mobile {
        display: block;
    }

    .m-hidden-mobile {
        display: none !important;
    }
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}