/* =============================================================================
   GLOBAL TOOLBAR RESPONSIVE CSS
   Áp dụng cho toàn dự án để xử lý toolbar overflow và responsive design
   ============================================================================= */

/* DevExtreme Toolbar Base Overrides */
.dx-toolbar, 
.dx-treelist-toolbar, 
.dx-datagrid-toolbar {
    overflow: visible !important;
    flex-wrap: wrap !important;
    min-height: 40px !important;
    padding: 8px !important;
}

.dx-toolbar-items-container {
    overflow: visible !important;
    flex-wrap: wrap !important;
    gap: 4px !important;
    width: 100% !important;
}

/* Toolbar Overflow Container */
.toolbar-overflow-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: 100%;
    min-height: 40px;
}

.toolbar-primary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.toolbar-secondary-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: auto;
}

/* Button Group Responsive */
.btn-group {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 2px !important;
    margin-bottom: 4px !important;
}

.btn-group .btn {
    margin-bottom: 2px !important;
    white-space: nowrap !important;
    min-width: auto !important;
    flex-shrink: 0;
}

/* DevExtreme Button Overrides */
.dx-widget.dx-button {
    margin-right: 2px !important;
    margin-bottom: 2px !important;
}

.dx-button-content {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

/* Material Icons Standardization */
.material-symbols-outlined {
    font-size: 18px !important;
    line-height: 1 !important;
    font-weight: 400 !important;
    font-style: normal !important;
    display: inline-block !important;
    white-space: nowrap !important;
    word-wrap: normal !important;
    direction: ltr !important;
    font-feature-settings: 'liga' !important;
    -webkit-font-smoothing: antialiased !important;
}

/* Button Size Standardization */
.btn-sm {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
    line-height: 1.5 !important;
    border-radius: 0.2rem !important;
}

/* Responsive Text Behavior */
.btn .d-none.d-sm-inline {
    margin-left: 4px;
}

/* =============================================================================
   RESPONSIVE BREAKPOINTS
   ============================================================================= */

/* Large Desktop (1200px and up) */
@media (min-width: 1200px) {
    .toolbar-overflow-container {
        flex-wrap: nowrap;
    }
    
    .btn-group {
        flex-wrap: nowrap !important;
    }
}

/* Desktop (992px to 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .btn-group .btn {
        padding: 0.25rem 0.4rem !important;
        font-size: 0.8rem !important;
    }
    
    .btn .d-none.d-md-inline {
        display: none !important;
    }
}

/* Tablet (768px to 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    .btn-group .btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.875rem !important;
    }
    
    .toolbar-secondary-actions {
        margin-left: 0;
        margin-top: 4px;
        width: 100%;
        justify-content: flex-start;
    }
}

/* Mobile Landscape (576px to 767px) */
@media (max-width: 767px) and (min-width: 576px) {
    .toolbar-overflow-container {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .toolbar-primary-actions,
    .toolbar-secondary-actions {
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }
    
    .btn-group {
        justify-content: center !important;
        width: 100% !important;
    }
    
    .btn-group .btn {
        flex: 1 1 auto !important;
        max-width: 120px !important;
        justify-content: center !important;
    }
    
    .btn .d-none.d-sm-inline {
        display: inline !important;
    }
}

/* Mobile Portrait (up to 575px) */
@media (max-width: 575px) {
    .toolbar-overflow-container {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    
    .toolbar-primary-actions,
    .toolbar-secondary-actions {
        width: 100%;
        flex-direction: column;
        margin-left: 0;
    }
    
    .btn-group {
        flex-direction: column !important;
        width: 100% !important;
        gap: 4px !important;
    }
    
    .btn-group .btn {
        width: 100% !important;
        margin-bottom: 4px !important;
        justify-content: flex-start !important;
        text-align: left !important;
    }
    
    .btn .d-none.d-sm-inline {
        display: inline !important;
    }
    
    .btn .material-symbols-outlined {
        margin-right: 8px !important;
    }
    
    /* Stack buttons vertically on very small screens */
    .dx-toolbar-items-container {
        flex-direction: column !important;
        align-items: stretch !important;
    }
}

/* =============================================================================
   UTILITY CLASSES
   ============================================================================= */

/* Toolbar Spacing */
.toolbar-gap-sm { gap: 4px !important; }
.toolbar-gap-md { gap: 8px !important; }
.toolbar-gap-lg { gap: 12px !important; }

/* Button Priority Classes */
.btn-priority-high {
    order: -3;
}

.btn-priority-medium {
    order: -2;
}

.btn-priority-low {
    order: -1;
}

/* Toolbar Action Groups */
.toolbar-action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

.toolbar-action-group + .toolbar-action-group {
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid #dee2e6;
}

@media (max-width: 767px) {
    .toolbar-action-group + .toolbar-action-group {
        margin-left: 0;
        margin-top: 8px;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid #dee2e6;
        padding-top: 8px;
    }
}

/* =============================================================================
   SPECIFIC COMPONENT OVERRIDES
   ============================================================================= */

/* DevExtreme Grid/TreeList Toolbar Specific */
.dx-datagrid .dx-toolbar,
.dx-treelist .dx-toolbar {
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
    border-radius: 0.375rem 0.375rem 0 0;
}

/* Button States */
.btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

.btn:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

/* =============================================================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================================================= */

/* Focus States */
.btn:focus,
.dx-button:focus {
    outline: 2px solid #007bff !important;
    outline-offset: 2px !important;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn {
        border-width: 2px !important;
    }
    
    .material-symbols-outlined {
        font-weight: 600 !important;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .btn:not(:disabled):hover {
        transform: none;
        transition: none;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .toolbar-overflow-container,
    .dx-toolbar,
    .btn-group {
        display: none !important;
    }
}
