/*
© 2025 Sharon Aicler (saichler@gmail.com)

Layer 8 Ecosystem is licensed under the Apache License, Version 2.0.
You may obtain a copy of the License at:

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/**
 * MobilePopup Styles
 */

.mobile-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.mobile-popup-overlay.open {
    opacity: 1;
    visibility: visible;
}

.mobile-popup {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    max-height: 95vh;
    max-height: 95dvh;
    overflow: hidden;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
}

.mobile-popup-overlay.open .mobile-popup {
    transform: translateY(0);
}

/* Size variants */
.mobile-popup.size-small {
    max-height: 40vh;
    max-height: 40dvh;
}

.mobile-popup.size-medium {
    max-height: 60vh;
    max-height: 60dvh;
}

.mobile-popup.size-large {
    max-height: 85vh;
    max-height: 85dvh;
}

.mobile-popup.size-full {
    max-height: 95vh;
    max-height: 95dvh;
    border-radius: 0;
    top: 0;
}

/* Drag handle */
.mobile-popup-handle {
    width: 36px;
    height: 5px;
    background: var(--border-default);
    border-radius: 3px;
    margin: var(--spacing-sm) auto;
    flex-shrink: 0;
    cursor: grab;
}

.mobile-popup.size-full .mobile-popup-handle {
    display: none;
}

/* Header */
.mobile-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.mobile-popup-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.mobile-popup-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-left: var(--spacing-sm);
    transition: background var(--transition-fast);
}

.mobile-popup-close:active {
    background: var(--border-light);
}

/* Body */
.mobile-popup-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--spacing-md);
    background: var(--bg-secondary);
}

.mobile-popup-body.no-padding {
    padding: 0;
}

/* Footer */
.mobile-popup-footer {
    display: flex;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-primary);
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
    padding-bottom: calc(var(--spacing-md) + var(--sab));
}

.mobile-popup-btn {
    flex: 1;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity var(--transition-fast);
}

.mobile-popup-btn:active {
    opacity: 0.7;
}

.mobile-popup-btn-cancel {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.mobile-popup-btn-save {
    background: var(--layer8d-primary);
    color: white;
}

.mobile-popup-btn-danger {
    background: var(--status-terminated);
    color: white;
}

/* Tabs */
.mobile-popup-tabs {
    display: flex;
    gap: 4px;
    padding: 0 var(--spacing-md);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}

.mobile-popup-tabs::-webkit-scrollbar {
    display: none;
}

.mobile-popup-tab {
    flex-shrink: 0;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}

.mobile-popup-tab.active {
    color: var(--layer8d-primary);
    border-bottom-color: var(--layer8d-primary);
}

.mobile-popup-tab-content {
    display: none;
}

.mobile-popup-tab-content.active {
    display: block;
}

/* Form styles inside popup */
.mobile-popup-section {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--border-light);
}

.mobile-popup-section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-sm);
}

.mobile-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-light);
}

.mobile-popup-row:last-child {
    border-bottom: none;
}

.mobile-popup-row-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.mobile-popup-row-value {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    font-weight: 500;
    text-align: right;
    word-break: break-word;
    margin-left: var(--spacing-sm);
}

/* Loading state */
.mobile-popup-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl);
    color: var(--text-secondary);
}

.mobile-popup-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-light);
    border-top-color: var(--layer8d-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: var(--spacing-sm);
}

/* Stacked popups */
.mobile-popup-overlay.stacked {
    z-index: 1010;
}

.mobile-popup-overlay.stacked .mobile-popup {
    z-index: 1011;
}

.mobile-popup-overlay.stacked-2 {
    z-index: 1020;
}

/* Tablet styles */
@media (min-width: 768px) {
    .mobile-popup {
        left: 50%;
        right: auto;
        bottom: auto;
        top: 50%;
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
        border-radius: var(--radius-lg);
        width: 90%;
        max-width: 550px;
        max-height: 80vh;
    }

    .mobile-popup-overlay.open .mobile-popup {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    .mobile-popup.size-small {
        max-width: 400px;
        max-height: 50vh;
    }

    .mobile-popup.size-large {
        max-width: 700px;
        max-height: 80vh;
    }

    .mobile-popup.size-full {
        top: 50%;
        max-width: 95vw;
        max-height: 95vh;
        border-radius: var(--radius-lg);
    }

    .mobile-popup-handle {
        display: none;
    }
}

/* Bottom sheet variant */
.mobile-popup.mobile-popup-bottom {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}
.mobile-popup-overlay.open .mobile-popup.mobile-popup-bottom {
    transform: translateY(0);
}
.mobile-popup.mobile-popup-bottom .mobile-popup-handle {
    display: block;
    width: 36px;
    height: 4px;
    background: var(--layer8d-border);
    border-radius: 2px;
    margin: 8px auto 4px;
}
