/* Shared Responsive CSS Utilities */

/* Responsive Padding Utilities */
.responsive-padding-sm {
    padding: 0.5rem;
}

.responsive-padding-md {
    padding: 1rem;
}

.responsive-padding-lg {
    padding: 1.5rem;
}

@media (min-width: 768px) {
    .responsive-padding-sm {
        padding: 1rem;
    }
    
    .responsive-padding-md {
        padding: 1.5rem;
    }
    
    .responsive-padding-lg {
        padding: 2rem;
    }
}

@media (min-width: 992px) {
    .responsive-padding-sm {
        padding: 1.5rem;
    }
    
    .responsive-padding-md {
        padding: 2rem;
    }
    
    .responsive-padding-lg {
        padding: 3rem;
    }
}

/* Responsive Margin Utilities */
.responsive-margin-sm {
    margin-bottom: 0.5rem;
}

.responsive-margin-md {
    margin-bottom: 1rem;
}

.responsive-margin-lg {
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .responsive-margin-sm {
        margin-bottom: 1rem;
    }
    
    .responsive-margin-md {
        margin-bottom: 1.5rem;
    }
    
    .responsive-margin-lg {
        margin-bottom: 2rem;
    }
}

/* Form Field Utilities */
.form-field-full-width {
    width: 100%;
}

.form-input-full-width {
    width: 100%;
}

.form-validator {
    display: block;
    font-size: 12px;
    color: var(--rz-danger);
    margin-top: 4px;
}

/* Button Utilities */
.button-full-width {
    width: 100%;
}

.button-center {
    text-align: center;
}

/* Container Utilities */
.container-responsive {
    max-width: 100%;
    width: 100%;
}

.container-max-width {
    max-width: 1440px;
    width: 100%;
}

/* Image Utilities */
.image-responsive {
    max-width: 100%;
    height: auto;
}

/* Page Header Pattern (Title + Actions) */
.page-header-row {
    margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
    .page-header-row {
        margin-bottom: 1rem;
    }
}

.page-header-title {
    margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
    .page-header-title {
        margin-bottom: 0;
    }
}

.page-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
}

@media (max-width: 767px) {
    .page-header-actions {
        width: 100%;
        justify-content: flex-start !important;
        margin-top: 0;
        padding: 0;
    }

    /* Ensure buttons don't overflow on mobile */
    .page-header-actions .rz-button,
    .page-header-actions .rz-splitbutton {
        flex-shrink: 1;
        min-width: 0;
    }

    /* Make columns in page header rows stack on mobile */
    .page-header-row .rz-col,
    .rz-row.page-header-row > .rz-col {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
    }

    /* Add spacing between stacked elements */
    .page-header-row .rz-col:not(:last-child) {
        margin-bottom: 0.75rem;
    }
}

/* Card Utilities */
.card-responsive {
    padding: 0;
    overflow: hidden;
    background-color: var(--rz-base-background-color);
    width: 100%;
    max-width: 100%;
}

/* Stack Utilities */
.stack-gap-responsive {
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .stack-gap-responsive {
        gap: 1rem;
    }
}

/* ============================================
   RESPONSIVE DATAGRID UTILITIES
   ============================================ */

/* Desktop DataGrid - Show on desktop, hide on mobile */
.rz-datagrid-desktop {
    display: block;
}

@media (max-width: 767px) {
    .rz-datagrid-desktop {
        display: none !important;
    }
}

/* Mobile DataGrid - Hide on desktop, show on mobile */
.rz-datagrid-mobile {
    display: none;
}

@media (max-width: 767px) {
    .rz-datagrid-mobile {
        display: block;
    }
}

/* Mobile Action Buttons - Legacy fallback for components not using RadzenStack */
.mobile-action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--rz-border-color);
}

@media (max-width: 767px) {
    .mobile-action-buttons {
        flex-direction: column;
        align-items: stretch;
    }

    .mobile-action-buttons .rz-button {
        width: 100%;
        box-sizing: border-box;
        justify-content: flex-start;
    }
}

/* Mobile Detail Row - Label/Value pairs in two-column layout */
.mobile-detail-row {
    display: grid;
    grid-template-columns: minmax(100px, auto) 1fr;
    gap: 1rem;
    align-items: start;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--rz-border-color);
}

.mobile-detail-row:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.mobile-detail-label {
    font-size: 0.75rem;
    color: var(--rz-text-secondary-color);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.4;
}

.mobile-detail-value {
    font-size: 0.875rem;
    color: var(--rz-text-color);
    word-break: break-word;
    line-height: 1.4;
}

/* Mobile Status Indicators */
.mobile-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.mobile-status-badge.online {
    background-color: rgba(76, 175, 80, 0.1);
    color: #4caf50;
}

.mobile-status-badge.offline {
    background-color: rgba(244, 67, 54, 0.1);
    color: #f44336;
}

/* ============================================
   RESPONSIVE DIALOG UTILITIES
   ============================================ */

/* Full-screen dialogs on mobile */
@media (max-width: 767px) {
    .rz-dialog-wrapper {
        padding: 0 !important;
    }

    .rz-dialog {
        max-width: 100% !important;
        width: 100% !important;
        height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
    }

    .rz-dialog-content {
        max-height: calc(100vh - 120px) !important;
        overflow-y: auto !important;
    }
}

/* Dialog with responsive width */
.dialog-responsive {
    width: 90%;
    max-width: 600px;
}

@media (min-width: 768px) {
    .dialog-responsive {
        width: 70%;
        max-width: 800px;
    }
}

@media (min-width: 992px) {
    .dialog-responsive {
        width: 60%;
        max-width: 1000px;
    }
}

/* Dialog button stack - Horizontal on desktop, vertical on mobile */
.dialog-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

@media (max-width: 767px) {
    .dialog-buttons {
        flex-direction: column;
        width: 100%;
    }

    .dialog-buttons .rz-button {
        width: 100%;
    }
}

/* ============================================
   RESPONSIVE FORM UTILITIES
   ============================================ */

/* Form columns - Stack on mobile */
.form-row-responsive {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .form-row-responsive {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .form-row-responsive.three-columns {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   RESPONSIVE LAYOUT UTILITIES
   ============================================ */

/* Hide on mobile */
.hide-mobile {
    display: block;
}

@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on tablet and up */
.hide-tablet-up {
    display: none;
}

@media (max-width: 767px) {
    .hide-tablet-up {
        display: block !important;
    }
}

/* Hide on desktop */
.hide-desktop {
    display: block;
}

@media (min-width: 992px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile-only {
    display: none;
}

@media (max-width: 767px) {
    .show-mobile-only {
        display: block !important;
    }
}

/* Responsive text alignment */
.text-center-mobile {
    text-align: left;
}

@media (max-width: 767px) {
    .text-center-mobile {
        text-align: center;
    }
}

/* ============================================
   MAINLAYOUT HEADER RESPONSIVE
   ============================================ */

/* Language dropdown - default desktop width */
.header-language-dropdown {
    width: 120px !important;
    min-width: 120px !important;
}

/* Header columns - Stack on mobile */
@media (max-width: 767px) {
    .main-header-container {
        padding: 0.5rem !important;
    }

    .main-header-left,
    .main-header-right {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0.25rem 0 !important;
    }

    .main-header-left .rz-stack {
        justify-content: flex-start;
    }

    .main-header-right .rz-stack {
        flex-wrap: nowrap;
        justify-content: flex-start !important;
        gap: 0.5rem;
        padding: 0 !important;
    }

    /* Language dropdown - compact on mobile, next to menu button */
    .header-language-dropdown {
        width: 90px !important;
        min-width: 90px !important;
    }

    /* Device picker - full width on mobile */
    .main-header-right .rz-autocomplete {
        flex: 1 1 auto;
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100%;
    }

    /* Logout button - compact on mobile */
    .main-header-right .rz-button {
        flex-shrink: 0;
    }
}

/* ============================================
   RESPONSIVE TABLE OVERFLOW
   ============================================ */

/* Horizontal scroll for tables on small screens */
.table-responsive-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
    .table-responsive-wrapper {
        margin: 0 -1rem;
        padding: 0 1rem;
    }
}

/* ============================================
   RESPONSIVE TABS
   ============================================ */

/* Make tabs scrollable on mobile to prevent overflow */
@media (max-width: 767px) {
    .rz-tabview-nav {
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        flex-wrap: nowrap !important;
    }

    .rz-tabview-nav::-webkit-scrollbar {
        height: 4px;
    }

    .rz-tabview-nav::-webkit-scrollbar-thumb {
        background: var(--rz-text-disabled-color);
        border-radius: 2px;
    }

    .rz-tabview-nav-link {
        white-space: nowrap;
        flex-shrink: 0;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
}

/* ============================================
   RESPONSIVE ACTION BUTTON STACKS
   ============================================ */

/* Allow action button stacks to wrap properly on all screen sizes */
.rz-stack.action-buttons,
.page-header-actions {
    flex-wrap: wrap !important;
}

@media (max-width: 767px) {
    /* Nested page action buttons - allow wrapping */
    .rz-stack[orientation="Horizontal"] {
        flex-wrap: wrap !important;
    }

    /* Action buttons inside cards/pages */
    .rz-card .rz-stack[orientation="Horizontal"],
    .page-content .rz-stack[orientation="Horizontal"] {
        gap: 0.5rem !important;
    }

    /* Prevent buttons from having fixed widths that cause deformation */
    .rz-button,
    .rz-splitbutton {
        min-width: fit-content !important;
        white-space: nowrap !important;
    }

    /* Split button text should be readable */
    .rz-splitbutton-menubutton {
        padding: 0.5rem !important;
    }
}

