/* ==========================================================================
   Research Papers Attachments - Frontend Styles
   Medical Modern Design
   ========================================================================== */

/* --------------------------------------------------------------------------
   BASE CONTAINER STYLES
   Main container for the downloads section
   -------------------------------------------------------------------------- */
.rpa-downloads-container {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    max-width: 100%;
    margin: 20px 0;
}

/* Section heading with medical blue accent */
.rpa-downloads-container h3 {
    color: #2c3e50;
    font-size: 1.5rem;
    margin-bottom: 20px;
    border-left: 5px solid #007bff;
    padding-left: 15px;
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   LOGIN REQUIRED OVERLAY SYSTEM
   Shows a blur effect and login prompt for non-logged-in users.
   The papers list remains visible but blurred to entice users to login.
   -------------------------------------------------------------------------- */

/* Wrapper that contains both the overlay and the blurred content */
.rpa-login-required-wrapper {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
}

/* Clickable overlay positioned above the blurred content */
.rpa-login-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Semi-transparent background - adjust opacity as needed */
    background: rgba(255, 255, 255, 0.3);
    text-decoration: none !important;
    cursor: pointer;
    transition: background 0.3s ease;
    /* Minimum height ensures overlay is always clickable */
    min-height: 200px;
}

/* Darken overlay slightly on hover for better UX feedback */
.rpa-login-overlay:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Login prompt text - bold and clear */
.rpa-login-text {
    display: inline-block;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #ffffff;
    font-size: 1.4rem;
    font-weight: 700;
    padding: 18px 40px;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 123, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    /* Prevent text selection */
    user-select: none;
}

/* Elevate button on hover */
.rpa-login-overlay:hover .rpa-login-text {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(0, 123, 255, 0.5);
}

/* Blur effect applied to the downloads list when user is not logged in */
.rpa-downloads-list.rpa-blurred {
    filter: blur(5px);
    /* Prevent interaction with blurred content */
    pointer-events: none;
    /* Smooth transition if state changes */
    transition: filter 0.3s ease;
}

/* Disabled state for download links (non-logged-in users) */
.rpa-download-link.rpa-disabled {
    cursor: default;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   DOWNLOADS LIST GRID
   Responsive grid layout for paper download cards
   -------------------------------------------------------------------------- */
.rpa-downloads-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* --------------------------------------------------------------------------
   DOWNLOAD ITEM CARDS
   Individual paper download card styling
   -------------------------------------------------------------------------- */
.rpa-download-item {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    border: 1px solid #eef2f7;
    display: flex;
    flex-direction: column;
    margin: 0 !important;
}

/* Hover effect for cards (only when not blurred) */
.rpa-download-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 123, 255, 0.15);
    border-color: #b8daff;
}

/* Download link wrapper */
.rpa-download-link {
    display: flex;
    flex-direction: column;
    text-decoration: none !important;
    height: 100%;
    color: inherit;
}

/* --------------------------------------------------------------------------
   CARD HEADER
   Top section with icon and gradient background
   -------------------------------------------------------------------------- */
.rpa-card-header {
    background: linear-gradient(135deg, #007bff 0%, #00c6ff 100%);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
}

/* Document icon in card header */
.rpa-icon-large {
    font-size: 40px;
    color: #fff;
    width: 40px;
    height: 40px;
    text-align: center;
}

/* --------------------------------------------------------------------------
   CARD BODY
   Content section with title, meta info, and download button
   -------------------------------------------------------------------------- */
.rpa-card-body {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Paper title */
.rpa-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.4;
    display: block;
}

/* Meta information row (file type + size) */
.rpa-meta-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    font-size: 0.85rem;
    color: #7f8c8d;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
}

/* File type badge (PDF, DOC, etc.) */
.rpa-badge {
    background-color: #e3f2fd;
    color: #007bff;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
}

/* File size display */
.rpa-size {
    display: flex;
    align-items: center;
}

/* Download action button */
.rpa-download-action {
    margin-top: 15px;
    text-align: center;
    background: #007bff;
    color: white;
    padding: 10px;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.2s;
}

/* Download button hover state */
.rpa-download-item:hover .rpa-download-action {
    background: #0056b3;
}

/* --------------------------------------------------------------------------
   VIEW BUTTON ICON
   Icon inside the View Paper button
   -------------------------------------------------------------------------- */
.rpa-download-action .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 4px;
}

/* ==========================================================================
   PDF VIEWER PAGE STYLES
   Styles for the [rpa_pdf_viewer] shortcode page
   ========================================================================== */

/* --------------------------------------------------------------------------
   VIEWER CONTAINER
   Main wrapper for the PDF viewer page - fills parent container
   -------------------------------------------------------------------------- */
.rpa-pdf-viewer-container {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Force full width on common theme/page builder wrappers */
.rpa-pdf-viewer-container,
.rpa-pdf-viewer-container * {
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   ELEMENTOR WIDTH OVERRIDES
   Ensure Elementor containers don't restrict the viewer width
   -------------------------------------------------------------------------- */

/* Target Elementor shortcode widget and its container */
.elementor-widget-shortcode .elementor-shortcode {
    width: 100%;
}

/* Ensure the shortcode widget takes full width of its container */
.elementor-widget-shortcode {
    width: 100%;
}

/* --------------------------------------------------------------------------
   VIEWER HEADER
   Title and meta information section
   -------------------------------------------------------------------------- */
.rpa-viewer-header {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #eef2f7;
}

.rpa-viewer-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 15px 0;
    line-height: 1.3;
}

.rpa-viewer-meta {
    display: flex;
    align-items: center;
    gap: 15px;
}

.rpa-viewer-badge {
    background: linear-gradient(135deg, #007bff 0%, #00c6ff 100%);
    color: #fff;
    padding: 5px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.rpa-viewer-size {
    color: #7f8c8d;
    font-size: 0.95rem;
}

/* --------------------------------------------------------------------------
   PDF IFRAME VIEWER
   Embedded PDF display area - fills available container width
   -------------------------------------------------------------------------- */
.rpa-viewer-frame-wrapper {
    background: #2d2d2d;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 25px;
    width: 100%;
}

.rpa-pdf-frame {
    width: 100%;
    height: 85vh;
    min-height: 600px;
    border: none;
    display: block;
}

/* --------------------------------------------------------------------------
   NO PREVIEW STATE
   Shown for non-PDF files
   -------------------------------------------------------------------------- */
.rpa-viewer-no-preview {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 60px 30px;
    text-align: center;
    margin-bottom: 25px;
}

.rpa-no-preview-icon {
    font-size: 80px;
    width: 80px;
    height: 80px;
    color: #bdc3c7;
    margin-bottom: 20px;
}

.rpa-viewer-no-preview p {
    color: #7f8c8d;
    font-size: 1.1rem;
    margin: 10px 0;
}

/* --------------------------------------------------------------------------
   ACTION BUTTONS
   Download and Back buttons
   -------------------------------------------------------------------------- */
.rpa-viewer-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.rpa-download-btn,
.rpa-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

/* Primary Download button */
.rpa-download-btn {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #fff !important;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.rpa-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
    color: #fff !important;
}

/* Secondary Back button */
.rpa-back-btn {
    background: #f8f9fa;
    color: #495057 !important;
    border: 2px solid #dee2e6;
}

.rpa-back-btn:hover {
    background: #e9ecef;
    border-color: #ced4da;
}

/* Button icons */
.rpa-download-btn .dashicons,
.rpa-back-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* --------------------------------------------------------------------------
   LOGIN REQUIRED STATE (VIEWER PAGE)
   Shown when non-logged-in user tries to access viewer page directly
   -------------------------------------------------------------------------- */
.rpa-viewer-login-required {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px 20px;
}

.rpa-viewer-login-box {
    background: #fff;
    border-radius: 16px;
    padding: 50px 40px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    max-width: 450px;
    width: 100%;
}

.rpa-lock-icon {
    font-size: 60px;
    width: 60px;
    height: 60px;
    color: #007bff;
    margin-bottom: 20px;
}

.rpa-viewer-login-box h2 {
    font-size: 1.8rem;
    color: #2c3e50;
    margin: 0 0 15px 0;
    font-weight: 700;
}

.rpa-viewer-login-box p {
    color: #7f8c8d;
    font-size: 1.1rem;
    margin: 0 0 25px 0;
}

.rpa-login-button {
    display: inline-block;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #fff !important;
    padding: 14px 40px;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.rpa-login-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.4);
    color: #fff !important;
}

/* --------------------------------------------------------------------------
   ERROR STATE
   Shown when paper is not found or invalid
   -------------------------------------------------------------------------- */
.rpa-viewer-error {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    border-left: 4px solid #e53e3e;
    color: #c53030;
    padding: 20px 25px;
    border-radius: 8px;
    font-size: 1rem;
}

/* --------------------------------------------------------------------------
   RESPONSIVE DESIGN
   Adjustments for smaller screens
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    /* Viewer container padding */
    .rpa-pdf-viewer-container {
        padding: 15px;
    }
    
    /* Smaller title */
    .rpa-viewer-title {
        font-size: 1.4rem;
    }
    
    /* Shorter PDF frame on tablets */
    .rpa-pdf-frame {
        height: 60vh;
        min-height: 400px;
    }
    
    /* Stack buttons vertically */
    .rpa-viewer-actions {
        flex-direction: column;
    }
    
    .rpa-download-btn,
    .rpa-back-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 600px) {
    /* Single column layout on mobile */
    .rpa-downloads-list {
        grid-template-columns: 1fr;
    }
    
    /* Smaller login text on mobile */
    .rpa-login-text {
        font-size: 1.1rem;
        padding: 14px 28px;
    }
    
    /* Even shorter PDF frame on mobile */
    .rpa-pdf-frame {
        height: 50vh;
        min-height: 350px;
    }
    
    /* Login box adjustments */
    .rpa-viewer-login-box {
        padding: 35px 25px;
    }
    
    .rpa-lock-icon {
        font-size: 50px;
        width: 50px;
        height: 50px;
    }
}