/**
 * IKIM Gated Content Blocks Styles
 */

/* Members Only Container Block */
.wp-block-ikim-members-only-container {
    margin: 2rem 0;
}

/* Container when user has access */
.wp-block-ikim-members-only-container.has-access {
    border: 2px solid #28a745;
    border-radius: 8px;
    background: linear-gradient(135deg, #f8fff9 0%, #e8f5e8 100%);
    padding: 0;
    position: relative;
}

.wp-block-ikim-members-only-container.has-access::before {
    content: "🔓 Members Only Content";
    display: block;
    background: #28a745;
    color: white;
    padding: 8px 16px;
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 6px 6px 0 0;
}

.wp-block-ikim-members-only-container.has-access .members-only-inner-content {
    padding: 2rem;
}

/* Container when access is denied */
.wp-block-ikim-members-only-container.no-access {
    border: 2px solid #6c757d;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(108, 117, 125, 0.1);
}

.access-denied-container {
    padding: 0;
}

.access-denied-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.5rem;
    background: linear-gradient(135deg, #40464c 0%, #495057 100%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.access-denied-icon {
    font-size: 24px;
    opacity: 0.9;
}

.access-denied-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.access-denied-message {
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
}

.access-denied-message p {
    margin: 0;
    color: #495057;
    text-align: center;
    font-size: 16px;
    line-height: 1.5;
}

.access-denied-actions {
    padding: 1.5rem;
    text-align: center;
    background: white;
}

.access-denied-actions p {
    margin: 0 0 1.5rem 0;
    color: #6c757d;
}

.access-action-button {
    display: inline-block;
    background: #002896;
    color: white;
    text-decoration: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0, 40, 150, 0.2);
}

.access-action-button:hover {
    background: #001f7a;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 40, 150, 0.3);
}

/* Login form within the container */
.member-login-form-wrapper {
    max-width: 400px;
    margin: 0 auto;
}

.member-login-form-wrapper .ikim-member-login-form {
    margin: 0;
    box-shadow: none;
    border: 1px solid #dee2e6;
}

/* Content group styling */
.wp-block-ikim-members-only-container[data-content-group]:not([data-content-group=""]).has-access::before {
    content: "🔓 Members Only: " attr(data-content-group);
}

/* Responsive design */
@media (max-width: 768px) {
    .wp-block-ikim-members-only-container.has-access .members-only-inner-content {
        padding: 1.5rem;
    }
    
    .access-denied-header,
    .access-denied-message,
    .access-denied-actions {
        padding: 1rem;
    }
    
    .access-denied-header {
        flex-direction: column;
        text-align: center;
        gap: 8px;
    }
    
    .access-denied-icon {
        font-size: 32px;
    }
}

/* File action styles */
.wp-block-ikim-gated-content-file .file-action {
    margin-top: 12px;
}

/* Block Editor Styles */
.ikim-block-placeholder {
    text-align: center;
    padding: 40px 20px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: #fafafa;
    margin: 20px 0;
}

.ikim-block-placeholder .placeholder-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.7;
}

.ikim-block-placeholder h3 {
    margin: 0 0 10px 0;
    color: #1e1e1e;
    font-size: 18px;
}

.ikim-block-placeholder p {
    margin: 0 0 20px 0;
    color: #757575;
}

/* File Selection Modal */
.ikim-file-selection-modal .components-modal__content {
    width: 90vw;
    max-width: 800px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

.file-selection-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.file-selection-filters {
    padding: 20px 0;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
}

.file-selection-filters .filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 15px;
}

.file-selection-list {
    flex: 1;
    overflow-y: auto;
    min-height: 300px;
}

.loading-state {
    text-align: center;
    padding: 40px 20px;
}

.loading-state .components-spinner {
    margin-bottom: 15px;
}

.files-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)) !important;
    gap: 12px !important;
    padding: 10px 0;
    background: #ffffcc !important; /* Temporary - should show yellow background */
}

.file-item {
    border: 2px solid #ff0000 !important; /* Temporary - should show red border */
    border-radius: 6px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    min-height: 80px;
}

.file-item:hover {
    border-color: #0073aa;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.1);
}

.file-item.selected {
    border-color: #0073aa;
    background: #f0f8ff;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.2);
}

.file-item .file-icon {
    font-size: 28px;
    margin-bottom: 8px;
    text-align: center;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-item .file-name {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    color: #1e1e1e;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    width: 100%;
}

.file-item .file-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.file-item .file-size {
    font-size: 12px;
    color: #757575;
}

.tier-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
}

.tier-badge.tier-public-gated {
    background-color: #e3f2fd;
    color: #1565c0;
}

.tier-badge.tier-members-only {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.file-item .file-group {
    font-size: 11px;
    color: #757575;
    margin-bottom: 4px;
}

.file-item .file-tags {
    font-size: 11px;
    color: #999;
    font-style: italic;
}

.modal-actions {
    padding: 20px 0 0 0;
    border-top: 1px solid #ddd;
    text-align: right;
}

/* Single File Block Preview */
.ikim-gated-file-preview {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    background: #fff;
    margin: 20px 0;
}

.ikim-gated-file-preview .file-info h4 {
    margin: 0 0 10px 0;
    color: #1e1e1e;
    font-size: 16px;
}

.ikim-gated-file-preview .file-meta {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 15px;
}

.ikim-gated-file-preview .file-description {
    margin-bottom: 15px;
    color: #757575;
}

.ikim-gated-file-preview .file-access-button {
    margin-bottom: 15px;
}

.preview-controls {
    padding-top: 15px;
    border-top: 1px solid #f0f0f0;
}

/* File Showcase Preview */
.ikim-file-showcase-preview {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    background: #fff;
    margin: 20px 0;
}

.showcase-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.showcase-controls .file-count {
    font-size: 12px;
    color: #757575;
}

.files-showcase.grid {
    display: grid;
    gap: 15px;
}

.files-showcase.list .showcase-file-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.files-showcase.list .showcase-file-item:last-child {
    border-bottom: none;
}

.showcase-file-item {
    position: relative;
}

.showcase-file-item .file-preview {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    background: #fafafa;
    position: relative;
}

.showcase-file-item .file-icon {
    font-size: 20px;
    margin-bottom: 8px;
    text-align: center;
}

.showcase-file-item .file-details h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #1e1e1e;
    line-height: 1.3;
}

.showcase-file-item .remove-file-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    min-width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    background: #dc3232;
    color: #fff;
    border: none;
    font-size: 12px;
    line-height: 1;
}

.showcase-file-item .remove-file-btn:hover {
    background: #c62d2d;
}

/* Inspector Controls */
.full-width-button {
    width: 100%;
    justify-content: center;
    margin-bottom: 15px;
}

.selected-file-info {
    background: #f0f8ff;
    border: 1px solid #0073aa;
    border-radius: 4px;
    padding: 10px;
    margin: 15px 0;
}

.selected-file-info p {
    margin: 0;
    font-size: 12px;
    color: #0073aa;
}

/* Loading States */
.loading-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: #757575;
}

.loading-placeholder .components-spinner {
    margin-bottom: 15px;
}

/* Frontend Styles */
.wp-block-ikim-gated-content-file {
    margin: 20px 0;
}

.wp-block-ikim-file-showcase {
    margin: 20px 0;
}

.ikim-gated-file {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ikim-gated-file .file-info {
    margin-bottom: 15px;
}

.ikim-gated-file .file-info h4 {
    margin: 0 0 10px 0;
    color: #1e1e1e;
    font-size: 18px;
}

.ikim-gated-file .file-meta {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-bottom: 10px;
}

.ikim-gated-file .file-size {
    font-size: 14px;
    color: #757575;
}

.ikim-gated-file .file-description {
    margin-bottom: 15px;
    color: #757575;
    line-height: 1.6;
}

.ikim-gated-file .access-button {
    display: inline-block;
    padding: 12px 24px;
    background-color: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    border: none;
    cursor: pointer;
}

.ikim-gated-file .access-button:hover {
    background-color: #005a87;
    color: #fff;
}

.ikim-gated-file .access-link {
    color: #0073aa;
    text-decoration: underline;
    font-weight: 500;
}

.ikim-gated-file .access-link:hover {
    color: #005a87;
}

/* File Showcase Frontend */
.ikim-file-showcase {
    margin: 20px 0;
}

.ikim-file-showcase.style-grid {
    display: grid;
    gap: 20px;
}

.ikim-file-showcase.style-list .showcase-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.ikim-file-showcase.style-list .showcase-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.showcase-item {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.showcase-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.showcase-item .file-icon {
    font-size: 32px;
    text-align: center;
    margin-bottom: 15px;
    opacity: 0.7;
}

.showcase-item .file-title {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #1e1e1e;
    line-height: 1.4;
}

.showcase-item .file-info {
    margin-bottom: 15px;
}

.showcase-item .access-button {
    width: 100%;
    text-align: center;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .file-selection-filters .filter-row {
        grid-template-columns: 1fr;
    }
    
    .files-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .ikim-gated-file .file-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .showcase-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .ikim-file-showcase.style-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .files-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

/* Accessibility */
.file-item:focus,
.showcase-item:focus,
.access-button:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.tier-badge {
    /* Ensure sufficient color contrast */
    font-weight: 600;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-item,
.showcase-item {
    animation: fadeIn 0.3s ease-out;
}

/* Frontend Display Styles for Gated Content File Block - IKIM Theme Match */
.wp-block-ikim-gated-content-file {
    margin: 1.5rem 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}


/* Card Style - IKIM Theme */
.wp-block-ikim-gated-content-file.style-card {
    border: 1px solid #e3e6ea;
    border-radius: 8px;
    padding: 24px;
    background: #FFFFFF;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    max-width: 340px;
    margin: 1.5rem auto;
}

.wp-block-ikim-gated-content-file.style-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transform: translateY(-4px);
    border-color: #002896;
}

.wp-block-ikim-gated-content-file.style-card .file-info {
    margin-bottom: 20px;
}

.wp-block-ikim-gated-content-file.style-card .file-title {
    font-size: 20px;
    margin: 0 0 12px 0;
    color: #40464c;
    line-height: 1.2;
    font-family: 'Montserrat', var(--font-primary);
    font-weight: 700;
    min-height: 120px;
    display: flex;
    align-items: center;
}

.wp-block-ikim-gated-content-file.style-card .file-meta {
    margin-bottom: 16px;
}

.wp-block-ikim-gated-content-file.style-card .file-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.wp-block-ikim-gated-content-file.style-card .file-details span {
    font-size: 14px;
    color: #6c757d;
    line-height: 1.4;
}

.wp-block-ikim-gated-content-file.style-card .file-details span strong {
    color: #40464c;
    font-weight: 600;
}

/* Thumbnail styles for frontend */
.wp-block-ikim-gated-content-file .file-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e3e6ea;
    background: #f8f9fa;
    margin-bottom: 16px;
}

.wp-block-ikim-gated-content-file .file-header-with-thumbnail {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.wp-block-ikim-gated-content-file .file-header-with-thumbnail .file-thumbnail {
    flex-shrink: 0;
    margin-bottom: 0;
}

.wp-block-ikim-gated-content-file .file-header-with-thumbnail .file-header-info {
    flex: 1;
    min-width: 0;
}

.wp-block-ikim-gated-content-file.style-card .file-description {
    margin-bottom: 20px;
    color: #6c757d;
    font-size: 14px;
    line-height: 1.5;
}

.wp-block-ikim-gated-content-file.style-card .access-button,
.wp-block-ikim-gated-content-file.style-card .access-link {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    text-align: center;
    width: 100%;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    background: #002896;
    color: #FFFFFF !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.wp-block-ikim-gated-content-file.style-card .access-button:hover,
.wp-block-ikim-gated-content-file.style-card .access-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(64, 70, 76, 0.3);
    color: #FFFFFF !important;
    text-decoration: none;
}

/* Print Styles */
@media print {
    .preview-controls,
    .showcase-controls,
    .remove-file-btn {
        display: none;
    }
    
    .ikim-gated-file,
    .showcase-item {
        border: 1px solid #000;
        box-shadow: none;
    }
    
    .access-button {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #000;
    }
}