/* =============================================================================
 * header.css - Unified header and filter dropdown styles
 * ============================================================================= */

/* -----------------------------------------------------------------------------
 * App Header
 * ----------------------------------------------------------------------------- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-height: 56px;
}

.header-menu-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.header-menu-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.header-title {
    flex: 1;
    margin: 0 16px;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.header-filter-btn {
    position: relative;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.header-filter-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.header-filter-btn.active {
    background: rgba(255, 255, 255, 0.3);
}

/* Filter badge */
.filter-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #dc3545;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
}

.filter-badge.active {
    display: flex;
}

/* Back button in header */
.header-back-btn {
    width: auto;
    padding: 0 12px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    transition: background 0.2s;
}

.header-back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* -----------------------------------------------------------------------------
 * Filter Dropdown
 * ----------------------------------------------------------------------------- */
.filter-dropdown-wrapper {
    position: relative;
}

.filter-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 300px;
    max-height: 80vh;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 1200;
    overflow: visible;
}

.filter-dropdown.open {
    display: block;
    animation: filterDropdownFadeIn 0.15s ease-out;
}

@keyframes filterDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.filter-dropdown-header h6 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.filter-dropdown-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}

.filter-dropdown-close:hover {
    opacity: 1;
}

.filter-dropdown-body {
    padding: 16px;
    max-height: 50vh;
    overflow: visible;
}

.filter-group {
    margin-bottom: 16px;
}

.filter-group:last-child {
    margin-bottom: 0;
}

.filter-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group input[type="date"],
.filter-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-group input[type="date"]:focus,
.filter-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

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

.filter-date-range input {
    flex: 1;
}

.filter-date-separator {
    color: #999;
    font-size: 14px;
}

/* Status checkboxes */
.filter-status-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.filter-status-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.filter-status-item span {
    font-size: 14px;
    color: #333;
}

/* Multi-select status dropdown in filter panel (dropdown mode) */
.filter-status-select {
    position: relative;
    width: 100%;
}

.filter-status-trigger {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-status-trigger:hover {
    border-color: #667eea;
}

.filter-status-trigger.open {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.filter-status-trigger i {
    font-size: 12px;
    transition: transform 0.2s;
}

.filter-status-trigger.open i {
    transform: rotate(180deg);
}

.filter-status-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 1300;
    max-height: 200px;
    overflow-y: auto;
}

.filter-status-options.open {
    display: block;
    animation: filterDropdownFadeIn 0.15s ease-out;
}

.filter-status-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    /* Reset label styles from .filter-group */
    text-transform: none;
    font-size: 13px;
    font-weight: 400;
    color: #333;
    margin-bottom: 0;
    letter-spacing: normal;
}

.filter-status-option:hover {
    background: #f5f5f5;
}

.filter-status-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #667eea;
    flex-shrink: 0;
}

.filter-status-option span {
    font-size: 13px;
    color: #333;
}

.filter-dropdown-footer {
    padding: 12px 16px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    background: #f9f9f9;
}

.filter-dropdown-footer .btn {
    flex: 1;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 6px;
}

.btn-filter-reset {
    background: white;
    border: 1px solid #ddd;
    color: #666;
}

.btn-filter-reset:hover {
    background: #f5f5f5;
}

.btn-filter-apply {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

.btn-filter-apply:hover {
    opacity: 0.9;
}

/* -----------------------------------------------------------------------------
 * Backdrop for dropdown (click outside to close)
 * ----------------------------------------------------------------------------- */
.filter-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1150;
    display: none;
}

.filter-backdrop.active {
    display: block;
}

/* -----------------------------------------------------------------------------
 * Inline Filters (desktop pages: fasovka, upakovka, turnover)
 * ----------------------------------------------------------------------------- */
.header-inline-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.header-filter-input {
    height: 32px;
    padding: 0 8px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    color: #333;
    min-width: 130px;
}

.header-filter-input:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
}

.header-filter-separator {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

/* Status dropdown with checkboxes */
.header-status-dropdown {
    position: relative;
}

.header-status-btn {
    height: 32px;
    padding: 0 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    color: #333;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.header-status-btn:hover {
    background: rgba(255, 255, 255, 1);
}

.header-status-btn i {
    font-size: 12px;
    transition: transform 0.2s;
}

.header-status-btn.open i {
    transform: rotate(180deg);
}

.header-status-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    min-width: 160px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 8px 0;
    display: none;
    z-index: 1200;
}

.header-status-menu.open {
    display: block;
    animation: filterDropdownFadeIn 0.15s ease-out;
}

.header-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    transition: background 0.15s;
}

.header-status-item:hover {
    background: #f5f5f5;
}

.header-status-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #667eea;
}

.header-apply-btn {
    height: 32px;
    padding: 0 16px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    min-width: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.header-apply-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.header-apply-btn:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* Spinner in apply button */
.header-apply-btn .spinner-border {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* -----------------------------------------------------------------------------
 * Mobile adjustments
 * ----------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .header-inline-filters {
        gap: 4px;
    }

    .header-filter-input {
        min-width: 110px;
        font-size: 12px;
        padding: 0 6px;
    }

    .header-status-btn {
        font-size: 12px;
        padding: 0 8px;
    }

    .header-apply-btn {
        min-width: 70px;
        padding: 0 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 8px 12px;
    }

    .header-title {
        font-size: 16px;
        margin: 0 8px;
    }

    .filter-dropdown {
        width: calc(100vw - 24px);
        right: -4px;
    }

    /* Hide inline filters on very small screens - they use dropdown instead */
    .header-inline-filters {
        display: none;
    }
}
