/* ============================================
   PROSEPT - Главный файл стилей
   ============================================ */

/* CSS Variables */
:root {
    /* Цвета */
    --prosept-blue: #1e3a8a;
    --prosept-accent: #3b82f6;
    --sidebar-width: 260px;
    --navbar-height: 56px;
    
    /* Тени */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Переходы */
    --transition-base: all 0.2s ease-in-out;
}

/* ============================================
   Базовые стили
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* Резервируем место для scrollbar, чтобы избежать "дергания" */
    overflow-y: scroll;
    /* Современный способ (для новых браузеров) */
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: #212529;
    background-color: #f8f9fa;
    /* Убираем margin для предсказуемой ширины */
    margin: 0;
}

/* ============================================
   Навигация
   ============================================ */

.navbar {
    height: var(--navbar-height);
    z-index: 1030;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    transition: var(--transition-base);
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.nav-link {
    transition: var(--transition-base);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.2);
    font-weight: 500;
}

/* ============================================
   Боковое меню
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    position: sticky;
    top: var(--navbar-height);
    overflow-y: auto;
    transition: var(--transition-base);
    align-self: flex-start;
    flex: 0 0 var(--sidebar-width);
    min-width: var(--sidebar-width);
}

.sidebar-content {
    height: 100%;
}

.sidebar .nav-link {
    color: #495057;
    padding: 0.625rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: 0.375rem;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
}

.sidebar .nav-link:hover {
    background-color: #e9ecef;
    color: #0d6efd;
    transform: translateX(4px);
}

.sidebar .nav-link.active {
    background-color: #0d6efd;
    color: white;
    font-weight: 500;
}

.sidebar .nav-link i {
    font-size: 1.125rem;
}

/* ============================================
   Основной контент
   ============================================ */

.main-content {
    padding: 1.5rem;
    background-color: #f8f9fa;
    min-width: 0;
}

/* ============================================
   Уведомления
   ============================================ */

.alerts-container {
    position: fixed;
    top: calc(var(--navbar-height) + 1rem);
    right: 1rem;
    z-index: 1050;
    max-width: 400px;
}

.alert {
    box-shadow: var(--shadow-lg);
    border: none;
    animation: slideInRight 0.3s ease-out;
}

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

/* ============================================
   Карточки
   ============================================ */

.card {
    border: none;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-base);
    border-radius: 0.5rem;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background-color: white;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* ============================================
   Таблицы
   ============================================ */

.table {
    background-color: white;
    border-radius: 0.5rem;
    overflow: hidden;
}

.table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    color: #6c757d;
    padding: 1rem;
}

.table tbody tr {
    transition: var(--transition-base);
}

.table-hover tbody tr:hover {
    background-color: #f8f9fa;
    transform: scale(1.01);
}

.table td {
    vertical-align: middle;
    padding: 1rem;
}

/* ============================================
   Кнопки
   ============================================ */

.btn {
    transition: var(--transition-base);
    font-weight: 500;
    border-radius: 0.375rem;
    padding: 0.5rem 1rem;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}

/* ============================================
   Формы
   ============================================ */

.form-control,
.form-select {
    border-radius: 0.375rem;
    border: 1px solid #ced4da;
    transition: var(--transition-base);
}

.form-control:focus,
.form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #495057;
}

/* ============================================
   Бейджи
   ============================================ */

.badge {
    font-weight: 500;
    padding: 0.375rem 0.75rem;
    border-radius: 0.375rem;
}

/* Статусы поставок */
.badge-draft {
    background-color: #6c757d;
    color: #fff;
}

.badge-uploaded {
    background-color: #0dcaf0;
    color: #000;
}

.badge-in-progress {
    background-color: #ffc107;
    color: #000;
}

.badge-completed {
    background-color: #198754;
    color: #fff;
}

.badge-ready-to-ship {
    background-color: #0d6efd;
    color: #fff;
}

.badge-shipped {
    background-color: #6f42c1;
    color: #fff;
}

/* ============================================
   Footer
   ============================================ */

.footer {
    margin-top: auto;
    background-color: white;
}

/* ============================================
   Утилиты
   ============================================ */

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hover-shadow {
    transition: var(--transition-base);
}

.hover-shadow:hover {
    box-shadow: var(--shadow-lg);
}

/* ============================================
   Адаптивность
   ============================================ */

@media (max-width: 991.98px) {
    .sidebar {
        display: none;
    }
    
    .main-content {
        padding: 1rem;
    }
    
    .alerts-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
}

@media (max-width: 767.98px) {
    .navbar-brand span {
        display: none;
    }
    
    .main-content {
        padding: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .table td,
    .table th {
        padding: 0.5rem;
    }
}

/* ============================================
   Анимации
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* ============================================
   Скроллбар
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   Печать
   ============================================ */

@media print {
    .navbar,
    .sidebar,
    .footer,
    .btn,
    .alerts-container {
        display: none !important;
    }
    
    .main-content {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}


/* ============================================
   Select2 кастомизация
   ============================================ */

.select2-result-product {
    padding: 4px 0;
}

.select2-result-product__article {
    font-weight: 600;
    color: #0d6efd;
    font-size: 0.875rem;
}

.select2-result-product__name {
    color: #6c757d;
    font-size: 0.813rem;
    margin-top: 2px;
}

.select2-container--bootstrap-5 .select2-selection {
    min-height: 38px;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
}


/* ============================================
   Select2 в Django Admin
   ============================================ */

.select2-result-product-admin {
    padding: 4px 0;
}

.select2-result-product-admin__article {
    font-weight: 600;
    color: #0d6efd;
    font-size: 0.875rem;
}

.select2-result-product-admin__name {
    color: #6c757d;
    font-size: 0.813rem;
    margin-top: 2px;
}

/* Адаптация Select2 под стили Django Admin */
.django-admin .select2-container--bootstrap-5 .select2-selection {
    min-height: 30px;
    border: 1px solid #ccc;
}

.django-admin .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 28px;
    padding-left: 8px;
}

.django-admin .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 28px;
}
