/**
 * Sidebar Panel Component
 * Modern replacement for Thickbox modal popups
 * Responsive slide-in panel for iframe content
 */

/* ========================================
   1. OVERLAY
   ======================================== */

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 300ms ease-in-out, visibility 300ms ease-in-out;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   2. SIDEBAR PANEL
   ======================================== */

.sidebar-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    background: #ffffff;
    box-shadow: -2px 0 30px rgba(0, 0, 0, 0.3);
    border-left: 1px solid #ccc;
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 300ms ease-in-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-panel.open {
    transform: translateX(0);
}

/* Size variants - Desktop (> 1024px) */
.sidebar-panel.size-small {
    width: 35vw;
    min-width: 400px;
    max-width: 500px;
}

.sidebar-panel.size-medium {
    width: 45vw;
    min-width: 500px;
    max-width: 650px;
}

.sidebar-panel.size-large {
    width: 55vw;
    min-width: 650px;
    max-width: 800px;
}

.sidebar-panel.size-xlarge {
    width: 65vw;
    min-width: 800px;
    max-width: 1000px;
}

/* ========================================
   3. HEADER
   ======================================== */

.sidebar-header {
    flex: 0 0 auto;
    height: 60px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.sidebar-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-right: 20px;
}

.sidebar-close-btn {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    background: #e0e0e0;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 24px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms, color 200ms;
    padding: 0;
    font-family: Arial, sans-serif;
}

.sidebar-close-btn:hover {
    background: #d0d0d0;
    color: #333;
}

.sidebar-close-btn:active {
    background: #c0c0c0;
}

.sidebar-close-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.sidebar-close-text {
    display: none;
    font-size: 14px;
    font-weight: normal;
    margin-left: 8px;
}

/* ========================================
   4. CONTENT AREA
   ======================================== */

.sidebar-content {
    flex: 1 1 auto;
    position: relative;
    overflow: hidden;
    background: #fff;
}

.sidebar-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ========================================
   5. LOADING STATE
   ======================================== */

.sidebar-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 1;
    transition: opacity 200ms ease-in-out;
}

.sidebar-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.sidebar-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: sidebar-spin 1s linear infinite;
}

@keyframes sidebar-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.sidebar-loading-text {
    margin-top: 20px;
    font-size: 16px;
    color: #666;
}

/* ========================================
   6. BODY SCROLL LOCK
   ======================================== */

body.sidebar-open {
    overflow: hidden;
}

/* ========================================
   7. RESPONSIVE - TABLET (768px - 1024px)
   ======================================== */

@media (max-width: 1024px) {
    /* All sizes become 70vw on tablet */
    .sidebar-panel.size-small,
    .sidebar-panel.size-medium,
    .sidebar-panel.size-large,
    .sidebar-panel.size-xlarge {
        width: 70vw;
        min-width: 0;
        max-width: none;
    }

    /* Adjust header for smaller screens */
    .sidebar-header {
        padding: 0 15px;
    }

    .sidebar-title {
        font-size: 16px;
    }

    .sidebar-close-btn {
        width: 36px;
        height: 36px;
        font-size: 20px;
    }
}

/* ========================================
   8. RESPONSIVE - MOBILE (< 768px)
   ======================================== */

@media (max-width: 768px) {
    /* Full screen on mobile */
    .sidebar-panel.size-small,
    .sidebar-panel.size-medium,
    .sidebar-panel.size-large,
    .sidebar-panel.size-xlarge {
        width: 95vw;
        min-width: 0;
        max-width: none;
    }

    /* Larger touch targets */
    .sidebar-close-btn {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }

    /* Show close text on mobile for clarity */
    .sidebar-close-btn {
        width: auto;
        padding: 0 12px;
    }

    .sidebar-close-text {
        display: inline;
    }

    /* Adjust header */
    .sidebar-header {
        padding: 0 10px;
    }

    .sidebar-title {
        font-size: 14px;
        padding-right: 10px;
    }
}

/* ========================================
   9. PRINT STYLES
   ======================================== */

@media print {
    .sidebar-overlay,
    .sidebar-panel {
        display: none;
    }
}

/* ========================================
   10. ACCESSIBILITY
   ======================================== */

/* Focus visible for keyboard navigation */
.sidebar-panel:focus {
    outline: none;
}

.sidebar-close-btn:focus-visible {
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .sidebar-overlay,
    .sidebar-panel,
    .sidebar-close-btn,
    .sidebar-loading {
        transition: none;
    }

    .sidebar-spinner {
        animation: none;
        border-top-color: #007bff;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .sidebar-panel {
        border-left: 2px solid #000;
    }

    .sidebar-header {
        border-bottom: 2px solid #000;
    }

    .sidebar-close-btn {
        border: 2px solid #000;
    }
}
