/* Custom CSS for PaintWorks - Responsive visibility fix
 *
 * Problem: MudBlazor CSS utility classes (d-none, d-md-flex) don't work reliably
 * Solution: Custom classes with !important to force correct responsive behavior
 *
 * Breakpoints:
 * - Mobile: < 960px (xs, sm)
 * - Desktop: >= 960px (md, lg, xl, xxl)
 */

/* Mobile toolbar - visible on mobile, hidden on desktop */
.mobile-toolbar {
    display: flex !important;
    flex-direction: column !important;
}

/* Desktop toolbar - hidden on mobile, visible on desktop */
.desktop-toolbar {
    display: none !important;
}

/* Desktop breakpoint (960px and up) */
@media (min-width: 960px) {
    .mobile-toolbar {
        display: none !important;
    }

    .desktop-toolbar {
        display: flex !important;
        flex-direction: row !important;
    }
}

/* Table action buttons - closer spacing on mobile */
@media (max-width: 959px) {
    /* Reduce spacing between action buttons on mobile */
    .mud-table-cell .mud-button-root + .mud-button-root {
        margin-left: -8px !important;
    }

    /* Slightly larger touch target for mobile */
    .mud-table-cell .mud-icon-button {
        min-width: 40px !important;
        min-height: 40px !important;
    }
}

/* ========================================
 * FilterDrawer Component (ETAP 9)
 * Advanced mobile UX with sticky search, bottom drawer, and FAB
 * ========================================
 */

/* Sticky search bar - always visible at top */
.filter-drawer-sticky-search {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--mud-palette-surface);
    padding: 8px 16px;
    border-bottom: 1px solid var(--mud-palette-divider);
}

/* Active filter chips container */
.filter-drawer-chips {
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Floating Action Button - fixed bottom-right */
.filter-drawer-fab {
    position: fixed !important;
    bottom: 16px !important;
    right: 16px !important;
    z-index: 99 !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3) !important;
    border-radius: 50% !important;
    width: 56px !important;
    height: 56px !important;
}

/* Safe area for devices with notch (iOS) */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .filter-drawer-fab {
        bottom: calc(16px + env(safe-area-inset-bottom));
        right: calc(16px + env(safe-area-inset-right));
    }
}

/* Bottom drawer content padding */
.filter-drawer-container .mud-drawer-content {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Hide FilterDrawer on desktop - use ListPageToolbar instead */
@media (min-width: 960px) {
    .filter-drawer-container {
        display: none !important;
    }
}

/* ========================================
 * ResponsiveActions & ActionButton (ETAP 10)
 * Responsive action buttons - desktop: buttons, mobile: menu
 * ========================================
 */

/* Mobile: Show menu, hide individual buttons */
.responsive-actions-buttons {
    display: none !important;
}

.responsive-actions-menu {
    display: block !important;
}

/* Desktop: Show individual buttons, hide menu */
@media (min-width: 960px) {
    .responsive-actions-buttons {
        display: flex !important;
    }

    .responsive-actions-menu {
        display: none !important;
    }
}

/* ActionButton: Mobile version (inside menu) visible by default */
.action-button-desktop {
    display: none !important;
}

.action-button-mobile {
    display: block !important;
}

/* ActionButton: Desktop version visible on large screens */
@media (min-width: 960px) {
    .action-button-desktop {
        display: block !important;
    }

    .action-button-mobile {
        display: none !important;
    }
}

/* ========================================
 * Typography Preview Scaling (Settings)
 * Uses CSS variable for dynamic font size preview
 * ========================================
 */

.typography-preview-box {
    border: 1px dashed var(--mud-palette-divider);
    border-radius: 4px;
    transform: scale(1);
    transform-origin: top left;
    display: inline-block;
    width: 100%;
}

/* ========================================
 * Skip to Main Content Link (WCAG 2.4.1)
 * Accessibility: Hidden by default, visible on keyboard focus
 * ========================================
 */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    z-index: 9999;
    padding: 8px 16px;
    background-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    text-decoration: none;
    border-radius: 0 0 4px 0;
    font-weight: 500;
    transition: top 0.2s ease-in-out;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid var(--mud-palette-primary-darken);
    outline-offset: 2px;
}

/* ===================================================================
   PWA Update Notification - Full Brand Integration
   @author Bartłomiej Cieślak
   @copyright © 2024 CIEŚLAK.APP
   =================================================================== */

/* MudSnackbar customization for PWA update notifications */
.mud-snackbar.mud-alert-info {
    background-color: #FDB913 !important; /* PaintWorks brand color */
    color: rgba(0, 0, 0, 0.87) !important; /* Dark text for contrast */
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(253, 185, 19, 0.5); /* Brand color glow */
    border-left: 4px solid rgba(0, 0, 0, 0.2);
}

/* Icon styling */
.mud-snackbar.mud-alert-info .mud-snackbar-icon {
    color: rgba(0, 0, 0, 0.87) !important;
}

/* Action button styling */
.mud-snackbar.mud-alert-info .mud-button {
    background-color: rgba(0, 0, 0, 0.87) !important;
    color: #FDB913 !important;
    font-weight: 700;
    padding: 8px 16px;
    min-width: 120px;
    transition: all 0.3s ease-out;
}

.mud-snackbar.mud-alert-info .mud-button:hover {
    background-color: rgba(0, 0, 0, 0.95) !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Close button */
.mud-snackbar.mud-alert-info .mud-icon-button {
    color: rgba(0, 0, 0, 0.6) !important;
}

.mud-snackbar.mud-alert-info .mud-icon-button:hover {
    color: rgba(0, 0, 0, 0.87) !important;
    background-color: rgba(0, 0, 0, 0.1) !important;
}

/* Animation */
@keyframes pwaSlideIn {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mud-snackbar.mud-alert-info {
    animation: pwaSlideIn 0.3s ease-out;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    .mud-snackbar.mud-alert-info {
        font-size: 14px;
    }

    .mud-snackbar.mud-alert-info .mud-button {
        min-width: 100px;
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mud-snackbar.mud-alert-info {
        border: 2px solid #000;
    }
}

/* ========================================
 * OrderCard Component (Reports Page)
 * Responsive card styling for order selection
 * ========================================
 */

.cursor-pointer {
    cursor: pointer;
}

.cursor-pointer:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1) !important;
}

.transition-all {
    transition: all 0.2s ease-in-out;
}

/* ========================================
 * Reception Workstation - Enlarged Input Fields
 * Larger fields and bigger fonts for faster data entry
 * @author Bartłomiej Cieślak
 * ========================================
 */

/* Reception Input - Large size with CSS variables */
.reception-input-large {
    --input-font-size: 1.5rem;
    --input-font-weight: 500;
    --label-font-size: 1.125rem;
    --label-font-weight: 600;
    --input-min-height: 56px;
}

.reception-input-large .mud-input-root {
    font-size: var(--input-font-size) !important;
    font-weight: var(--input-font-weight);
}

.reception-input-large .mud-input-label {
    font-size: var(--label-font-size) !important;
    font-weight: var(--label-font-weight);
}

.reception-input-large .mud-input-slot {
    min-height: var(--input-min-height) !important;
}

/* Validation error styling for Reception inputs */
.reception-input-error .mud-input-root {
    border: 2px solid var(--mud-palette-error) !important;
    background-color: rgba(244, 67, 54, 0.05) !important;
}

.reception-input-error .mud-input-label {
    color: var(--mud-palette-error) !important;
}

/* Mobile: slightly smaller input font */
@media (max-width: 959px) {
    .reception-input-large {
        --input-font-size: 1.25rem;
    }
}

/* ========================================
 * ADAPTIVE GRID LAYOUT (2025-12-03)
 * Grid always stretched to footer (max height)
 * @author Bartłomiej Cieślak / Claude Code
 * ======================================== */

/* Container - flexbox for dynamic resize */
.adaptive-grid-container {
    display: flex;
    flex-direction: column;
    flex: 1; /* Automatically adjusts when window resizes */
}

/* Filters section - auto height based on content */
.adaptive-grid-filters {
    flex: 0 0 auto; /* Don't grow/shrink */
    margin-bottom: 16px;
}

/* Grid content - fills remaining space with MIN/MAX HEIGHT constraints */
.adaptive-grid-content {
    flex: 1 1 0; /* Always grow to fill available space */
    overflow-y: auto; /* Scrollbar only here */
    overflow-x: hidden;
    position: relative; /* For FixedHeader positioning */

    /* NOWE: Minimum 400px widoczności + dynamiczna max-height */
    min-height: 400px; /* Gwarantuje minimum 400px grida na wszystkich urządzeniach */
    max-height: calc(100vh - 306px); /* Mobile overhead: AppBar + Title + Padding + FilterDrawer + Pagination + Footer */
    max-height: calc(100dvh - 306px); /* Modern browsers */

    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
}

/* Tablet: nieco większy overhead (filtry mogą być widoczne) */
@media (min-width: 600px) and (max-width: 1279px) {
    .adaptive-grid-content {
        min-height: 400px; /* Ujednolicona wysokość na wszystkich urządzeniach */
        max-height: calc(100vh - 330px);
        max-height: calc(100dvh - 330px);
    }
}

/* Desktop: pełne filtry widoczne */
@media (min-width: 1280px) {
    .adaptive-grid-content {
        min-height: 400px; /* Ujednolicona wysokość na wszystkich urządzeniach */
        max-height: calc(100vh - 366px);
        max-height: calc(100dvh - 366px);
    }
}

/* Fallback dla przeglądarek bez dvh (Safari < 15.4) */
@supports not (height: 100dvh) {
    .adaptive-grid-content {
        min-height: 400px; /* Ujednolicona wysokość na wszystkich urządzeniach */
        max-height: calc(100vh - 306px);
    }

    @media (min-width: 600px) and (max-width: 1279px) {
        .adaptive-grid-content {
            min-height: 400px; /* Ujednolicona wysokość na wszystkich urządzeniach */
            max-height: calc(100vh - 330px);
        }
    }

    @media (min-width: 1280px) {
        .adaptive-grid-content {
            min-height: 400px; /* Ujednolicona wysokość na wszystkich urządzeniach */
            max-height: calc(100vh - 366px);
        }
    }
}

/* Pagination section - auto height */
.adaptive-grid-pagination {
    flex: 0 0 auto;
    margin-top: 16px;
}

/* Remove MudDataGrid/MudTable fixed height when inside adaptive container */
.adaptive-grid-content .mud-data-grid,
.adaptive-grid-content .mud-table-container,
.adaptive-grid-content .mud-table {
    height: 100% !important; /* Override inline Height="50vh" */
}

/* Ensure FixedHeader stays at top of scroll container */
.adaptive-grid-content .mud-table-head {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--mud-palette-surface);
}

/* Custom scrollbar styling (Webkit browsers) */
.adaptive-grid-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.adaptive-grid-content::-webkit-scrollbar-track {
    background: var(--mud-palette-surface);
}

.adaptive-grid-content::-webkit-scrollbar-thumb {
    background: var(--mud-palette-divider);
    border-radius: 4px;
}

.adaptive-grid-content::-webkit-scrollbar-thumb:hover {
    background: var(--mud-palette-text-secondary);
}

/* Print: Remove scrollbars, show all content */
@media print {
    .adaptive-grid-content {
        overflow: visible !important;
        max-height: none !important;
    }
}

/* High contrast mode: Ensure borders are visible */
@media (prefers-contrast: high) {
    .adaptive-grid-content {
        border: 2px solid currentColor;
    }
}

/* ========================================
 * Rotating Refresh Button Animation
 * Used for refresh buttons during loading state
 * ======================================== */

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.mud-icon-button-rotate svg {
    animation: rotate 1s linear infinite;
}
