/* =============================================================================
   BASE.CSS - Общие стили приложения
   ============================================================================= */

/* CSS переменные */
:root {
    /* Цвета бренда */
    --color-primary: #667eea;
    --color-primary-dark: #764ba2;
    --color-primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    /* Цвета текста */
    --color-text-primary: #1a202c;
    --color-text-secondary: #475569;
    --color-text-muted: #94a3b8;

    /* Фоны */
    --color-bg-page: #f5f7fa;
    --color-bg-card: white;
    --color-bg-hover: #f8fafc;
    --color-bg-light: #f1f5f9;

    /* Границы */
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;

    /* Scrollbar */
    --scrollbar-width: 6px;
    --scrollbar-track: #f1f5f9;
    --scrollbar-thumb: #cbd5e1;
    --scrollbar-thumb-hover: #94a3b8;
}

/* Утилитарный класс для scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: var(--scrollbar-width);
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Общие стили */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: #f5f7fa;
    font-size: 13px;
    margin: 0;
    padding: 0;
    color: #1a202c;
    overflow-x: hidden;
}

/* Шапка */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding-left: 60px;
}

.header-title {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.date-label {
    font-size: 12px;
    color: rgba(255,255,255,0.9);
    margin: 0;
    font-weight: 500;
}

.date-input {
    width: 140px;
    font-size: 12px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: white;
    border-radius: 4px;
    padding: 4px 8px;
    height: 28px;
}

.date-input:focus {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    color: white;
    box-shadow: none;
}

.date-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

.status-dropdown-btn {
    min-width: 150px;
    font-size: 12px;
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.15);
    color: white;
    border-radius: 4px;
    padding: 4px 12px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    white-space: nowrap;
}

.status-dropdown-btn:hover,
.status-dropdown-btn:focus {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
    color: white;
}

.status-dropdown-btn::after {
    margin-left: 8px;
}

.status-dropdown-menu {
    font-size: 12px;
    min-width: 200px;
    max-height: 250px;
    overflow-y: auto;
    padding: 4px 0;
}

/* Scrollbar: добавить class="custom-scrollbar" к элементу */

.status-dropdown-menu .dropdown-item {
    padding: 4px 12px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.status-dropdown-menu .dropdown-item:hover {
    background-color: #f1f5f9;
}

.status-dropdown-menu .dropdown-item input[type="checkbox"] {
    cursor: pointer;
}

.status-dropdown-menu .btn-link {
    font-size: 11px;
    color: #667eea;
}

.status-dropdown-menu .btn-link:hover {
    color: #764ba2;
}

/* Чекбокс в header для фильтра разрывов цепочки */
#filterIncompleteChains {
    width: 14px;
    height: 14px;
    cursor: pointer;
    vertical-align: middle;
    accent-color: #667eea;
}

#filterIncompleteChains:hover {
    opacity: 0.8;
}

#filterIncompleteChains:checked {
    background-color: #667eea;
    border-color: #667eea;
}

/* Header buttons - прозрачные кнопки для градиентного header */
.btn-header {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    font-size: 12px;
    padding: 4px 16px;
    font-weight: 500;
    height: 28px;
    transition: all 0.2s;
}

.btn-header:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.4);
    color: white;
    transform: translateY(-1px);
}

/* Spinner в кнопке фильтрации */
#filterBtn .spinner-border {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

#filterBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */

.toast-container {
    pointer-events: none;
}

.toast-notification {
    pointer-events: auto;
    min-width: 300px;
    max-width: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    margin-bottom: 12px;
    animation: slideInRight 0.3s ease-out;
}

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

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

.toast-notification.hiding {
    animation: slideOutRight 0.3s ease-in forwards;
}

.toast-notification.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.toast-notification.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.toast-notification.info {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

.toast-header-custom {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.toast-body-custom {
    padding: 12px 16px;
    color: white;
    font-size: 13px;
    line-height: 1.5;
}

.toast-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.toast-close-btn:hover {
    opacity: 1;
}

.toast-icon {
    font-size: 18px;
    margin-right: 8px;
}

/* =============================================================================
   Sidebar Menu & Navigation
   ============================================================================= */

/* Бургер-кнопка (используется на страницах без app-header) */
.burger-menu-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1100;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* Скрыть глобальную burger-кнопку когда страница использует app-header */
body:has(.app-header) .burger-menu-btn {
    display: none;
}

.burger-menu-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.burger-menu-btn:active {
    transform: scale(0.95);
}

/* Sidebar */
.sidebar-menu {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: white;
    z-index: 1200;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}

.sidebar-menu.open {
    left: 0;
}

/* Sidebar Header */
.sidebar-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 600;
}

.sidebar-close-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.sidebar-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Navigation Menu */
.nav-menu {
    list-style: none;
    margin: 0;
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-menu-item {
    padding: 14px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #475569;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-menu-item:hover {
    background: #f1f5f9;
    color: #667eea;
}

.nav-menu-item.active {
    background: linear-gradient(to right, #eef2ff 0%, white 100%);
    border-left-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

.nav-menu-icon {
    font-size: 18px;
}

.nav-menu-text {
    flex: 1;
}

/* Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1150;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Page Container */
#page-container {
    min-height: 100vh;
}

/* =============================================================================
   Page Styles (for multi-page layout)
   ============================================================================= */

/* Общие стили страницы */
.page-content {
    min-height: 100vh;
    background-color: #f5f7fa;
}

.page-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    padding-left: 70px; /* Отступ для бургер-кнопки */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.page-body {
    padding: 20px;
}

/* Empty state container */
.empty-state-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.empty-state-text {
    font-size: 18px;
    color: #94a3b8;
    font-style: italic;
}

/* Общие стили фильтров для страниц подразделений */
.dept-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    padding: 16px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin: 16px 20px 20px 20px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label {
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    white-space: nowrap;
}

.filter-date-input {
    width: 140px;
    font-size: 12px;
}

.filter-separator {
    color: #94a3b8;
}

/* =============================================================================
   Tabulator Customization
   ============================================================================= */

.tabulator {
    border: none;
    font-size: 13px;
}

.tabulator .tabulator-header {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
}

.tabulator .tabulator-header .tabulator-col {
    background: transparent;
    border-right: 1px solid #e2e8f0;
}

.tabulator .tabulator-header .tabulator-col-content {
    padding: 8px 12px;
}

.tabulator .tabulator-header .tabulator-col-title {
    font-weight: 600;
    color: #475569;
}

.tabulator .tabulator-header .tabulator-header-filter input {
    font-size: 11px;
    padding: 4px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    margin-top: 4px;
}

.tabulator .tabulator-header .tabulator-header-filter input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row {
    border-bottom: 1px solid #f1f5f9;
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row:hover {
    background: #f8fafc;
}

.tabulator .tabulator-tableholder .tabulator-table .tabulator-row .tabulator-cell {
    padding: 8px 10px;
    border-right: none;
    vertical-align: middle;
}

/* Компактные ячейки - текст обрезается если не помещается */
.tabulator .tabulator-cell {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tabulator .tabulator-footer {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 8px 12px;
}

.tabulator .tabulator-footer .tabulator-paginator {
    color: #475569;
    font-size: 12px;
}

.tabulator .tabulator-footer .tabulator-page {
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    padding: 4px 10px;
    margin: 0 2px;
    background: white;
    color: #475569;
}

.tabulator .tabulator-footer .tabulator-page:hover {
    background: #f1f5f9;
    border-color: #667eea;
}

.tabulator .tabulator-footer .tabulator-page.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* Placeholder для пустой таблицы */
.tabulator-placeholder {
    padding: 40px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

/* Улучшенная типографика */
.product-name,
.order-number,
.batch-info {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =============================================================================
   Общие стили для модалок с градиентным header
   ============================================================================= */

/* Close button для модалок с темным/градиентным header */
.modal-header.gradient-header .btn-close,
.production-modal .modal-header .btn-close,
.modal-related .modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
    transition: opacity 0.2s;
}

.modal-header.gradient-header .btn-close:hover,
.production-modal .modal-header .btn-close:hover,
.modal-related .modal-header .btn-close:hover {
    opacity: 1;
}
