/**
 * Template Preview Module Styles
 * Follows the unified design system and matches image preview patterns
 */

/* ========================================
   MODAL STRUCTURE
   ======================================== */

.template-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.template-preview-modal.show {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   BACKDROP
   ======================================== */

.template-preview-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* ========================================
   CONTAINER
   ======================================== */

.template-preview-container {
    position: relative;
    width: 90vw;
    max-width: 800px;
    max-height: 90vh;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.template-preview-modal.show .template-preview-container {
    transform: scale(1);
}

/* ========================================
   CONTENT STRUCTURE
   ======================================== */

.template-preview-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 90vh;
}

.template-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.template-preview-body {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ========================================
   HEADER ELEMENTS
   ======================================== */

.template-preview-title {
    margin: 0;
    font-size: 1.4em;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.template-preview-group {
    margin: 5px 0 0 0;
    font-size: 0.9em;
    color: var(--text-secondary);
    font-weight: 500;
}

.template-preview-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    margin-left: 15px;
}

.template-preview-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: scale(1.1);
}

.template-preview-close:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========================================
   MESSAGE CONTENT
   ======================================== */

.template-preview-message {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    border: 2px solid var(--border-secondary);
    line-height: 1.6;
    font-size: 16px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.template-preview-message::-webkit-scrollbar {
    width: 6px;
}

.template-preview-message::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.template-preview-message::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: 3px;
}

.template-preview-message::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

/* ========================================
   ATTACHMENTS SECTION
   ======================================== */

.template-preview-attachments {
    flex-shrink: 0;
}

.template-attachment-section {
    margin-bottom: 20px;
}

.template-attachment-section:last-child {
    margin-bottom: 0;
}

.template-attachment-section h4 {
    margin: 0 0 12px 0;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-primary);
    padding-bottom: 8px;
}

/* ========================================
   IMAGE THUMBNAILS
   ======================================== */

.template-attachment-thumbnails {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.template-attachment-thumbnail {
    width: 96px;
    height: 96px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid var(--border-primary);
    transition: all 0.2s ease;
    background: var(--bg-secondary);
}

.template-attachment-thumbnail:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(193, 20, 158, 0.2);
}

.template-attachment-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ========================================
   FILE LIST
   ======================================== */

.template-attachment-list {
    list-style: disc;
    margin: 0;
    padding: 0 0 0 20px;
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}

.template-attachment-list li {
    margin-bottom: 8px;
    color: var(--text-primary);
}

.template-attachment-list li:last-child {
    margin-bottom: 0;
}

/* ========================================
   FOOTER
   ======================================== */

.template-preview-footer {
    flex-shrink: 0;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--border-primary);
}

.template-preview-notice {
    margin: 0;
    padding: 12px 16px;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 6px;
    color: var(--warning-color);
    font-size: 14px;
    text-align: center;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .template-preview-container {
        width: 95vw;
        max-height: 95vh;
        margin: 10px;
    }

    .template-preview-header {
        padding: 15px 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .template-preview-title {
        font-size: 1.2em;
    }

    .template-preview-close {
        position: absolute;
        top: 15px;
        right: 20px;
        margin-left: 0;
    }

    .template-preview-body {
        padding: 20px;
        gap: 15px;
    }

    .template-preview-message {
        font-size: 15px;
        padding: 15px;
        max-height: 250px;
    }

    .template-attachment-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
        gap: 10px;
    }

    .template-attachment-thumbnail {
        width: 84px;
        height: 84px;
    }
}

@media (max-width: 480px) {
    .template-preview-container {
        width: 98vw;
        max-height: 98vh;
        margin: 5px;
    }

    .template-preview-header {
        padding: 12px 15px;
    }

    .template-preview-body {
        padding: 15px;
    }

    .template-preview-message {
        font-size: 14px;
        padding: 12px;
        max-height: 200px;
    }

    .template-attachment-thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
        gap: 8px;
    }

    .template-attachment-thumbnail {
        width: 72px;
        height: 72px;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes templatePreviewFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.template-preview-modal.show .template-preview-container {
    animation: templatePreviewFadeIn 0.3s ease-out;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

.template-preview-modal:focus {
    outline: none;
}

.template-preview-close:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .template-preview-modal {
        position: static;
        display: block;
        opacity: 1;
        visibility: visible;
    }

    .template-preview-backdrop {
        display: none;
    }

    .template-preview-container {
        width: 100%;
        max-width: none;
        max-height: none;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .template-preview-close {
        display: none;
    }
}
