/**
 * TRCodex PDF Viewer - Frontend Styles
 * Modern inline PDF viewer with custom design
 */

/* Variables */
:root {
    --trcodex-primary: #E31E24;
    --trcodex-primary-hover: #c41a1f;
    --trcodex-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    --trcodex-radius: 16px;
    --trcodex-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== */
/* PDF VIEWER COMPONENT */
/* ==================== */

.trcodex-pdf-viewer {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    border-radius: var(--trcodex-radius);
    overflow: hidden;
    box-shadow: var(--trcodex-shadow);
    transition: var(--trcodex-transition);
}

.trcodex-pdf-viewer:hover {
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.18);
}

/* Header */
.trcodex-viewer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: linear-gradient(135deg, var(--primary-color, #E31E24) 0%, #ff4757 100%);
    color: #ffffff;
}

.trcodex-viewer-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.trcodex-viewer-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.trcodex-viewer-info {
    flex: 1;
    min-width: 0;
}

.trcodex-viewer-title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.trcodex-viewer-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
    flex-wrap: wrap;
}

.trcodex-viewer-separator {
    opacity: 0.5;
}

.trcodex-viewer-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.trcodex-viewer-btn {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff !important;
    cursor: pointer;
    transition: var(--trcodex-transition);
    text-decoration: none !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.trcodex-viewer-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.trcodex-viewer-btn-download {
    background: rgba(255, 255, 255, 0.2);
}

.trcodex-viewer-btn-download:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* PDF Viewer Body */
.trcodex-viewer-body {
    height: 600px;
    background: #525659;
    position: relative;
    overflow: hidden;
}

.trcodex-viewer-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Loading state */
.trcodex-viewer-body::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: trcodex-spin 1s linear infinite;
    z-index: 1;
    pointer-events: none;
}

.trcodex-viewer-iframe:not([src=""])~.trcodex-viewer-loading {
    display: none;
}

@keyframes trcodex-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Footer */
.trcodex-viewer-footer {
    padding: 20px 24px;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
    text-align: center;
}

.trcodex-viewer-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 40px;
    background: var(--primary-color, #E31E24);
    color: #ffffff !important;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none !important;
    cursor: pointer;
    transition: var(--trcodex-transition);
    position: relative;
    overflow: hidden;
}

.trcodex-viewer-download::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.trcodex-viewer-download:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(227, 30, 36, 0.4);
}

.trcodex-viewer-download:hover::before {
    left: 100%;
}

.trcodex-viewer-download svg {
    transition: transform 0.3s ease;
}

.trcodex-viewer-download:hover svg {
    animation: bounce-down 0.5s ease infinite;
}

@keyframes bounce-down {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(4px);
    }
}

/* Notice (Editor Mode) */
.trcodex-pdf-notice {
    padding: 40px 24px;
    background: linear-gradient(135deg, #fef3cd 0%, #fff3e0 100%);
    border: 2px dashed #ffc107;
    border-radius: 16px;
    color: #856404;
    text-align: center;
}

.trcodex-pdf-notice p {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
}

/* ==================== */
/* RESPONSIVE DESIGN    */
/* ==================== */

@media (max-width: 768px) {
    .trcodex-viewer-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .trcodex-viewer-header-left {
        gap: 12px;
    }

    .trcodex-viewer-icon {
        width: 40px;
        height: 40px;
    }

    .trcodex-viewer-icon svg {
        width: 22px;
        height: 22px;
    }

    .trcodex-viewer-title {
        font-size: 15px;
    }

    .trcodex-viewer-meta {
        font-size: 12px;
    }

    .trcodex-viewer-btn {
        width: 36px;
        height: 36px;
    }

    .trcodex-viewer-btn svg {
        width: 18px;
        height: 18px;
    }

    .trcodex-viewer-body {
        height: 450px;
    }

    .trcodex-viewer-footer {
        padding: 16px;
    }

    .trcodex-viewer-download {
        width: 100%;
        padding: 14px 24px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .trcodex-viewer-body {
        height: 350px;
    }

    .trcodex-viewer-meta span:last-child {
        display: none;
    }

    .trcodex-viewer-separator {
        display: none;
    }
}

/* ==================== */
/* DARK MODE SUPPORT    */
/* ==================== */

@media (prefers-color-scheme: dark) {
    .trcodex-pdf-viewer.auto-dark {
        background: #1e293b;
    }

    .trcodex-pdf-viewer.auto-dark .trcodex-viewer-footer {
        background: #1e293b;
        border-top-color: #334155;
    }
}