/**
 * ============================================================================
 * PORTION ENLARGEMENT MODAL STYLES - CROSS-BROWSER COMPATIBLE
 * ============================================================================
 */

/* ============================================================================
 * CROSS-BROWSER COMPATIBILITY FIXES
 * ============================================================================ */

/* Firefox scrollbar styling */
#portionEnlargementDialog .modal-body {
    scrollbar-width: thin;
    scrollbar-color: #8b8b8b #e0e0e0;
}

#portionEnlargementDialog .pe-controls-section {
    scrollbar-width: thin;
    scrollbar-color: #388538 #f1f1f1;
}

/* ============================================================================
 * MODAL CONTAINER OVERRIDES
 * ============================================================================ */

#portionEnlargementDialog .modal-dialog {
    width: 95%;
    max-width: 1400px;
    margin: 20px auto;
    float: none;
}

#portionEnlargementDialog .modal-dialog.center-block {
    float: none;
}

#portionEnlargementDialog .modal-content {
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: none;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

/* ============================================================================
 * HEADER SECTION - FIXED (OUTSIDE MODAL-BODY)
 * ============================================================================ */

#portionEnlargementDialog .pe-header {
    background-color: #388538;
    color: white;
    padding: 15px 20px;
    text-align: center;
    flex-shrink: 0;
    border-radius: 8px 8px 0 0;
}

#portionEnlargementDialog .pe-header h1 {
    margin: 0 0 6px 0;
    font-size: 22px;
    font-weight: 600;
}

#portionEnlargementDialog .pe-header .pe-subtitle {
    margin: 0;
    font-size: 13px;
    opacity: 0.9;
}

#portionEnlargementDialog .pe-header .photo-number {
    display: none;
}

/* ============================================================================
 * SCROLLABLE MODAL BODY
 * ============================================================================ */

#portionEnlargementDialog .modal-body {
    padding: 0;
    background-color: #f5f5f5;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    flex: 1;
}

/* Custom scrollbar for modal body - Chrome/Safari/Edge */
#portionEnlargementDialog .modal-body::-webkit-scrollbar {
    width: 8px;
}

#portionEnlargementDialog .modal-body::-webkit-scrollbar-track {
    background: #e0e0e0;
}

#portionEnlargementDialog .modal-body::-webkit-scrollbar-thumb {
    background: #8b8b8b;
    border-radius: 4px;
}

#portionEnlargementDialog .modal-body::-webkit-scrollbar-thumb:hover {
    background: #a5a5a5;
}

/* ============================================================================
 * MODAL FOOTER - FIXED
 * ============================================================================ */

#portionEnlargementDialog .modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    padding: 12px 15px;
    flex-shrink: 0;
    border-radius: 0 0 8px 8px;
}

/* ============================================================================
 * CONTENT AREA (REPLACED gap WITH margin)
 * ============================================================================ */

#portionEnlargementDialog .pe-content {
    display: flex;
    flex-wrap: nowrap;
    padding: 15px;
    background-color: #f5f5f5;
    position: relative;
    align-items: flex-start;
}

/* ============================================================================
 * CANVAS SECTION (LEFT PANEL)
 * ============================================================================ */

#portionEnlargementDialog .pe-canvas-section {
    flex: 1;
    min-width: 400px;
    margin-right: 15px; /* Replaces gap: 15px */
}

#portionEnlargementDialog .pe-canvas-wrapper {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 12px;
    position: relative;
}

/* ============================================================================
 * CANVAS TITLE (REPLACED gap WITH margin)
 * ============================================================================ */

#portionEnlargementDialog .pe-canvas-title {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

/* Add spacing between title elements */
#portionEnlargementDialog .pe-canvas-title > * {
    margin-right: 10px; /* Replaces gap: 10px */
}

#portionEnlargementDialog .pe-canvas-title > *:last-child {
    /* margin-left: 0; */
}

/* Text container for icon + label */
#portionEnlargementDialog .pe-canvas-title-text {
    display: inline-flex;
    align-items: center;
    margin: 0 auto;
}

#portionEnlargementDialog .pe-canvas-title i {
    margin-right: 8px;
    color: #388538;
}

#portionEnlargementDialog .pe-map-search-form {
    display: inline-block;
}

#portionEnlargementDialog #canvasParentDiv {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
}

#portionEnlargementDialog .canvas-container {
    max-width: 100%;
    border-radius: 4px;
    overflow: hidden;
}

#portionEnlargementDialog #canvasMessage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

/* ============================================================================
 * CONTROLS SECTION (RIGHT PANEL) - STICKY
 * ============================================================================ */

#portionEnlargementDialog .pe-controls-section {
    width: 300px;
    min-width: 280px;
    flex-shrink: 0;
    align-self: flex-start;
    position: sticky;
    top: 15px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px;
}

/* Subtle background for sticky controls on desktop */
@media (min-width: 992px) {
    #portionEnlargementDialog .pe-controls-section {
        background-color: #f5f5f5;
        border-radius: 8px;
        padding-left: 5px;
    }
}

/* Custom scrollbar for controls section - Chrome/Safari/Edge */
#portionEnlargementDialog .pe-controls-section::-webkit-scrollbar {
    width: 6px;
}

#portionEnlargementDialog .pe-controls-section::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

#portionEnlargementDialog .pe-controls-section::-webkit-scrollbar-thumb {
    background: #388538;
    border-radius: 3px;
}

#portionEnlargementDialog .pe-controls-section::-webkit-scrollbar-thumb:hover {
    background: #2d6b2d;
}

/* Visual feedback when controls are stuck */
#portionEnlargementDialog .pe-controls-section.is-stuck {
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.1);
}

#portionEnlargementDialog .pe-control-card {
    background-color: white;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
    margin-bottom: 10px;
    overflow: hidden;
}

#portionEnlargementDialog .pe-card-header {
    background-color: #f8f9fa;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

#portionEnlargementDialog .pe-card-header i {
    margin-right: 8px;
    color: #388538;
}

#portionEnlargementDialog .pe-card-body {
    padding: 12px;
}

/* ============================================================================
 * FORM CONTROLS
 * ============================================================================ */

#portionEnlargementDialog .pe-form-group {
    margin-bottom: 12px;
}

#portionEnlargementDialog .pe-form-group:last-child {
    margin-bottom: 0;
}

#portionEnlargementDialog .pe-form-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    margin-bottom: 6px;
}

#portionEnlargementDialog .pe-form-label .pe-value-display {
    font-weight: 600;
    color: #388538;
}

/* Slider styling */
#portionEnlargementDialog .slider.slider-horizontal {
    width: 100%;
}

#portionEnlargementDialog .slider-selection {
    background-color: #388538 !important;
    background-image: none !important;
}

#portionEnlargementDialog .slider-handle {
    background-color: #388538 !important;
    background-image: none !important;
}

/* Dropdown styling */
#portionEnlargementDialog .pe-dropdown {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    color: #333;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

#portionEnlargementDialog .pe-dropdown:focus {
    outline: none;
    border-color: #388538;
    box-shadow: 0 0 0 2px rgba(56, 133, 56, 0.1);
}

/* ============================================================================
 * BUTTONS
 * ============================================================================ */

#portionEnlargementDialog .pe-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

#portionEnlargementDialog .pe-btn i {
    margin-right: 6px;
    font-size: 12px;
}

#portionEnlargementDialog .pe-btn-primary {
    background-color: #388538;
    color: white;
}

#portionEnlargementDialog .pe-btn-primary:hover {
    background-color: #2d6b2d;
}

#portionEnlargementDialog .pe-btn-primary:disabled {
    background-color: #a5d6a5;
    cursor: not-allowed;
}

#portionEnlargementDialog .pe-btn-secondary {
    background-color: #6c757d;
    color: white;
}

#portionEnlargementDialog .pe-btn-secondary:hover {
    background-color: #5a6268;
}

#portionEnlargementDialog .pe-btn-outline {
    background-color: white;
    color: #388538;
    border: 1px solid #388538;
}

#portionEnlargementDialog .pe-btn-outline:hover {
    background-color: #388538;
    color: white;
}

#portionEnlargementDialog .pe-btn-block {
    width: 100%;
}

/* ============================================================================
 * BUTTON GROUP (REPLACED gap WITH margin)
 * ============================================================================ */

#portionEnlargementDialog .pe-btn-group {
    display: flex;
}

#portionEnlargementDialog .pe-btn-group .pe-btn {
    flex: 1;
    margin-right: 8px; /* Replaces gap: 8px */
}

#portionEnlargementDialog .pe-btn-group .pe-btn:last-child {
    margin-right: 0;
}

/* ============================================================================
 * MESSAGE AREAS
 * ============================================================================ */

#portionEnlargementDialog .pe-message-area {
    margin-top: 12px;
}

#portionEnlargementDialog .pe-message {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12px;
    display: none;
    margin: 0;
}

#portionEnlargementDialog .pe-message:not(:empty) {
    display: block;
}

#portionEnlargementDialog .pe-message-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#portionEnlargementDialog .pe-message-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    font-size: 14px !important;
}

#portionEnlargementDialog .pe-message-info {
    background-color: #e7f3ff;
    color: #004085;
    border: 1px solid #b8daff;
}

/* ============================================================================
 * LOADING OVERLAY
 * ============================================================================ */

#portionEnlargementDialog #searchOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 8px;
}

#portionEnlargementDialog #searchOverlay i {
    font-size: 40px;
    color: #388538;
    margin-bottom: 15px;
}

#portionEnlargementDialog #searchOverlay #loadingText {
    font-size: 16px;
    color: #333;
    font-weight: 500;
}

/* ============================================================================
 * MAP SEARCH LINK
 * ============================================================================ */

#portionEnlargementDialog .pe-map-search-link {
    display: inline-flex;
    align-items: center;
    color: #388538;
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 4px;
    background-color: rgba(56, 133, 56, 0.1);
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

#portionEnlargementDialog .pe-map-search-link:hover {
    background-color: rgba(56, 133, 56, 0.2);
    text-decoration: none;
}

#portionEnlargementDialog .pe-map-search-link img {
    width: 16px;
    height: 16px;
    margin-left: 6px;
}

/* ============================================================================
 * HELP TEXT
 * ============================================================================ */

#portionEnlargementDialog .pe-help-text {
    font-size: 12px;
    color: #666;
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: none;
}

/* ============================================================================
 * DEBUG SECTION (HIDDEN BY DEFAULT)
 * ============================================================================ */

#portionEnlargementDialog .pe-debug {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    padding: 10px;
    margin-top: 15px;
    font-family: monospace;
    font-size: 12px;
    color: #856404;
}

/* ============================================================================
 * CONFIRMATION MODAL STYLES
 * ============================================================================ */

/* Modal Header Variants */
.pe-modal-header-warning {
    background-color: #fff3cd;
    border-bottom: 1px solid #ffc107;
}

.pe-modal-header-warning .modal-title {
    color: #856404;
}

.pe-modal-header-warning .modal-title i {
    margin-right: 8px;
}

.pe-modal-header-info {
    background-color: #e7f3ff;
    border-bottom: 1px solid #b8daff;
}

.pe-modal-header-info .modal-title {
    color: #004085;
}

.pe-modal-header-info .modal-title i {
    margin-right: 8px;
}

/* Modal Body */
.pe-modal-body {
    padding: 25px;
    text-align: center;
}

.pe-modal-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.pe-modal-icon-warning {
    color: #ffc107;
}

.pe-modal-icon-info {
    color: #17a2b8;
}

.pe-modal-message {
    font-size: 15px;
    color: #333;
    line-height: 1.6;
    margin: 0;
}

/* ============================================================================
 * MODAL FOOTER (REPLACED gap WITH margin)
 * ============================================================================ */

.pe-modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 15px 20px;
    display: flex;
    justify-content: center;
}

.pe-modal-footer .pe-btn {
    margin-right: 10px; /* Replaces gap: 10px */
}

.pe-modal-footer .pe-btn:last-child {
    margin-right: 0;
}

/* Document Link */
.pe-doc-link {
    color: #388538;
    text-decoration: none;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 3px;
    background-color: rgba(56, 133, 56, 0.1);
    transition: all 0.2s;
}

.pe-doc-link:hover {
    background-color: rgba(56, 133, 56, 0.2);
    text-decoration: none;
}

.pe-doc-link i {
    margin-right: 4px;
    font-size: 12px;
}

/* Close Button Override */
#outOfRangeModal .close,
#confirmDocModal .close,
#confirmDocModal1963 .close {
    color: inherit;
    opacity: 0.6;
    font-size: 24px;
    font-weight: 300;
}

#outOfRangeModal .close:hover,
#confirmDocModal .close:hover,
#confirmDocModal1963 .close:hover {
    opacity: 1;
}

/* ============================================================================
 * AOI SIZE INFORMATION CARD
 * ============================================================================ */

.pe-aoi-info-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-left: 4px solid #388538;
}

.pe-aoi-info-card .pe-card-header {
    background-color: #388538;
    color: white;
}

/* ============================================================================
 * SIZE DISPLAY GRID (grid gap WITH fallback)
 * ============================================================================ */

.pe-aoi-size-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px; /* Modern browsers */
    margin-top: 12px;
}

/* Fallback for browsers that don't support grid gap */
@supports not (gap: 12px) {
    .pe-aoi-size-grid {
        gap: 0;
    }

    .pe-aoi-size-grid .pe-aoi-size-item {
        margin-right: 12px;
        margin-bottom: 12px;
    }

    .pe-aoi-size-grid .pe-aoi-size-item:nth-child(2n) {
        margin-right: 0; /* Remove margin from every 2nd item (right column) */
    }
}

.pe-aoi-size-item {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    transition: all 0.3s ease;
}

.pe-aoi-size-item:hover {
    border-color: #388538;
    box-shadow: 0 2px 8px rgba(56, 133, 56, 0.1);
}

/* ============================================================================
 * AOI SIZE LABEL (REPLACED gap WITH margin)
 * ============================================================================ */

.pe-aoi-size-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #333; /* ALWAYS DARK GREY */
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pe-aoi-size-label i {
    margin-right: 6px; /* Replaces gap: 6px */
    font-size: 14px;
    color: #333; /* ALWAYS DARK GREY - NEVER CHANGES */
}

/* ============================================================================
 * AOI SIZE VALUE (REPLACED gap WITH margin)
 * ============================================================================ */

.pe-aoi-size-value {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.pe-aoi-size-value > * {
    margin-bottom: 2px; /* Replaces gap: 2px */
}

.pe-aoi-size-value > *:last-child {
    margin-bottom: 0;
}

.pe-size-percentage {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    color: #333;
}

.pe-size-subtext {
    font-size: 11px;
    color: #999;
    font-weight: 500;
}

.pe-size-inches {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
}

.pe-size-cm {
    font-size: 11px;
    color: #888;
    font-weight: 400;
}

/* ============================================================================
 * MAXIMUM SIZE INFO (REPLACED gap WITH margin)
 * ============================================================================ */

.pe-aoi-max-info {
    background-color: #f0f7f0;
    border: 1px solid #c8e6c9;
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pe-aoi-max-info > * {
    margin-right: 10px; /* Replaces gap: 10px */
}

.pe-aoi-max-info > *:last-child {
    margin-right: 0;
}

.pe-aoi-max-label {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #2e7d32;
    font-weight: 600;
}

.pe-aoi-max-label i {
    margin-right: 6px; /* Replaces gap: 6px */
    font-size: 14px;
}

.pe-aoi-max-value {
    font-size: 13px;
    font-weight: 600;
    color: #1b5e20;
}

/* ============================================================================
 * STATUS INDICATORS (REPLACED gap WITH margin)
 * ============================================================================ */

.pe-aoi-status {
    margin-top: 12px;
}

.pe-aoi-status > div {
    display: none;
    align-items: center;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.pe-aoi-status > div i {
    margin-right: 8px; /* Replaces gap: 8px */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pe-aoi-status-ok {
    background-color: #e8f5e9;
    border: 1px solid #a5d6a7;
    color: #2e7d32;
}

.pe-aoi-status-ok i {
    color: #4caf50;
    font-size: 16px;
}

.pe-aoi-status-warning {
    background-color: #fff3e0;
    border: 1px solid #ffcc80;
    color: #e65100;
}

.pe-aoi-status-warning i {
    color: #ff9800;
    font-size: 16px;
}

.pe-aoi-status-error {
    background-color: #ffebee;
    border: 1px solid #ef9a9a;
    color: #c62828;
}

.pe-aoi-status-error i {
    color: #f44336;
    font-size: 16px;
}

/* ============================================================================
 * AOI SIZE ITEM - COLOR STATES
 * ============================================================================ */

/* OK Status (0-90%) - Grey Tones */
.pe-aoi-size-item.status-ok {
    border-color: #9e9e9e;
    background: linear-gradient(135deg, #fafafa 0%, #f5f5f5 100%);
}

.pe-aoi-size-item.status-ok .pe-size-percentage {
    color: #616161;
}

/* Label and icon ALWAYS stay #333 */
.pe-aoi-size-item.status-ok .pe-aoi-size-label,
.pe-aoi-size-item.status-ok .pe-aoi-size-label i {
    color: #333;
}

/* Warning Status (90-100%) - Orange */
.pe-aoi-size-item.status-warning {
    border-color: #ff9800;
    background: linear-gradient(135deg, #ffffff 0%, #fff8f0 100%);
}

.pe-aoi-size-item.status-warning .pe-size-percentage {
    color: #e65100;
}

/* Label and icon ALWAYS stay #333 */
.pe-aoi-size-item.status-warning .pe-aoi-size-label,
.pe-aoi-size-item.status-warning .pe-aoi-size-label i {
    color: #333;
}

/* Error Status (>100%) - Red with pulse animation */
.pe-aoi-size-item.status-error {
    border-color: #f44336;
    background: linear-gradient(135deg, #ffffff 0%, #ffebee 100%);
    animation: pulse-error 2s ease-in-out infinite;
}

.pe-aoi-size-item.status-error .pe-size-percentage {
    color: #c62828;
}

/* Label and icon ALWAYS stay #333 */
.pe-aoi-size-item.status-error .pe-aoi-size-label,
.pe-aoi-size-item.status-error .pe-aoi-size-label i {
    color: #333;
}

@keyframes pulse-error {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(244, 67, 54, 0);
    }
}

/* ============================================================================
 * LEGEND (REPLACED gap WITH margin)
 * ============================================================================ */

.pe-aoi-legend {
    display: flex;
    justify-content: space-around;
    margin-top: 16px;
    padding: 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.pe-legend-item {
    display: flex;
    align-items: center;
    font-size: 11px;
    color: #666;
}

.pe-legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 2px solid currentColor;
    margin-right: 6px; /* Replaces gap: 6px */
}

.pe-legend-ok {
    background: linear-gradient(135deg, #ffffff 0%, #f1f8f4 100%);
    border-color: #4caf50;
}

.pe-legend-warning {
    background: linear-gradient(135deg, #ffffff 0%, #fff8f0 100%);
    border-color: #ff9800;
}

.pe-legend-error {
    background: linear-gradient(135deg, #ffffff 0%, #ffebee 100%);
    border-color: #f44336;
}

.pe-legend-text {
    font-weight: 500;
}

/* ============================================================================
 * RESPONSIVE ADJUSTMENTS
 * ============================================================================ */

@media (min-width: 1200px) {
    #portionEnlargementDialog .modal-dialog {
        width: 95%;
        max-width: 1400px;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    #portionEnlargementDialog .modal-dialog {
        width: 95%;
        max-width: 1100px;
    }

    #portionEnlargementDialog .pe-controls-section {
        width: 280px;
    }
}

/* Disable sticky behavior on tablets and mobile */
@media (max-width: 991px) {
    #portionEnlargementDialog .pe-content {
        flex-direction: column;
        flex-wrap: wrap;
    }

    #portionEnlargementDialog .pe-canvas-section {
        max-width: 100%;
        min-width: 100%;
        margin-right: 0; /* Remove margin when stacked */
        margin-bottom: 15px; /* Add bottom margin when stacked */
    }

    #portionEnlargementDialog .pe-controls-section {
        width: 100%;
        position: static;
        max-height: none;
        overflow-y: visible;
        background-color: transparent;
        padding-left: 0;
    }

    #portionEnlargementDialog .modal-body {
        max-height: calc(100vh - 210px);
    }
}

@media (max-width: 767px) {
    #portionEnlargementDialog .modal-dialog {
        width: 98%;
        margin: 10px auto;
    }

    #portionEnlargementDialog .pe-header h1 {
        font-size: 18px;
    }

    #portionEnlargementDialog .pe-header {
        padding: 12px 15px;
    }

    /* Button group - stack vertically on mobile */
    #portionEnlargementDialog .pe-btn-group {
        flex-direction: column;
    }

    #portionEnlargementDialog .pe-btn-group .pe-btn {
        margin-right: 0;
        margin-bottom: 8px; /* Bottom margin when stacked */
    }

    #portionEnlargementDialog .pe-btn-group .pe-btn:last-child {
        margin-bottom: 0;
    }

    #portionEnlargementDialog .pe-content {
        padding: 10px;
    }

    #portionEnlargementDialog .pe-canvas-title {
        flex-direction: column;
        align-items: flex-start;
    }

    #portionEnlargementDialog .pe-map-search-form {
        margin-top: 10px;
    }

    #portionEnlargementDialog .modal-body {
        max-height: calc(100vh - 180px);
    }
}

@media (max-width: 768px) {
    .pe-aoi-size-grid {
        grid-template-columns: 1fr;
    }

    .pe-aoi-max-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .pe-aoi-max-info > * {
        margin-right: 0;
        margin-bottom: 6px;
    }

    .pe-aoi-max-info > *:last-child {
        margin-bottom: 0;
    }

    /* Legend - stack vertically on mobile */
    .pe-aoi-legend {
        flex-direction: column;
    }

    .pe-aoi-legend .pe-legend-item {
        margin-bottom: 8px;
    }

    .pe-aoi-legend .pe-legend-item:last-child {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    #portionEnlargementDialog .pe-canvas-section {
        min-width: 100%;
    }

    #portionEnlargementDialog #canvasParentDiv {
        min-height: 300px;
    }
}
