:root {
    --primary-bg: #0a0a0a;
    --secondary-bg: #1a1a1a;
    --accent-gold: #d4af37;
    --accent-gold-light: #f4e4a6;
    --text-primary: #ffffff;
    --text-secondary: #b8b8b8;
    --card-bg: #1f1f1f;
    --card-hover: #2a2a2a;
    --border-color: #333333;
    --shadow-glow: rgba(212, 175, 55, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--primary-bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    max-width: 100%;
    position: relative;
}

.cover-container {
    min-height: 100vh;
    padding: 60px 40px;
    max-width: 1400px;
    margin: 0 auto;
}

.cover-header {
    text-align: center;
    margin-bottom: 80px;
    animation: fadeInUp 0.8s ease-out;
}

.main-title {
    font-family: 'Playfair Display', serif;
    font-size: 4.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
    letter-spacing: -0.02em;
}

.subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 300;
    letter-spacing: 0.05em;
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 40px;
    margin-bottom: 80px;
}

.template-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid var(--border-color);
    position: relative;
    animation: fadeInUp 0.8s ease-out backwards;
}

.template-card:nth-child(1) { animation-delay: 0.1s; }
.template-card:nth-child(2) { animation-delay: 0.2s; }
.template-card:nth-child(3) { animation-delay: 0.3s; }
.template-card:nth-child(4) { animation-delay: 0.4s; }

.template-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 40px var(--shadow-glow);
    border-color: var(--accent-gold);
}

.template-preview {
    position: relative;
    width: 100%;
    padding-top: 75%;
    overflow: hidden;
    background: var(--secondary-bg);
}

.template-preview::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
    z-index: 1;
    pointer-events: none;
}

.template-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--secondary-bg);
}

.placeholder-image {
    font-size: 2rem;
    color: var(--text-secondary);
    font-weight: 600;
    opacity: 0.3;
}

.template-preview-iframe {
    position: absolute;
    top: 0;
    left: 0;
    border: none;
    transform-origin: top left;
    pointer-events: none;
    background: white;
    overflow: hidden;
    z-index: 0;
}

.template-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
    z-index: 2;
}

.template-card:hover .template-overlay {
    opacity: 1;
}

.view-btn {
    padding: 14px 32px;
    background: var(--accent-gold);
    color: var(--primary-bg);
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.view-btn:hover {
    background: var(--accent-gold-light);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.5);
}

.template-info {
    padding: 28px;
}

.template-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.template-description {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.cover-footer {
    text-align: center;
    padding-top: 60px;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Template Page Styles */
.template-page {
    min-height: 100vh;
    background: var(--primary-bg);
}

.template-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(26, 26, 26, 0.95);
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.3s ease;
    font-weight: 500;
}

.back-btn:hover {
    color: var(--accent-gold);
}

.back-btn::before {
    content: '←';
    font-size: 1.2rem;
}

.device-switcher {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.device-btn {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.device-btn:hover {
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.device-btn.active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: var(--primary-bg);
}

.template-viewer {
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 80px);
    height: calc(100vh - 80px);
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    max-width: 100%;
}

.viewport-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
    transition: all 0.4s ease;
    flex-shrink: 0;
    margin: 0 auto;
    max-width: 100%;
    box-sizing: border-box;
}

.viewport-container.desktop {
    height: calc(100vh - 160px);
    min-height: calc(100vh - 160px);
}

.viewport-container.desktop {
    width: 100%;
    max-width: 100%;
    margin: 0;
}

.viewport-container.tablet {
    width: 1024px;
    max-width: calc(100vw - 80px);
}

.viewport-container.tablet[data-orientation="landscape"] {
    width: 1024px;
    max-width: calc(100vw - 80px);
}

.viewport-container.tablet[data-orientation="portrait"],
.viewport-container.tablet-portrait {
    width: 768px;
    max-width: calc(100vw - 80px);
}

.viewport-container.mobile {
    width: 375px;
    max-width: calc(100vw - 80px);
}

.template-iframe {
    width: 100%;
    max-width: 100%;
    border: none;
    border-radius: 8px;
    background: white;
    transition: height 0.3s ease;
    display: block;
    box-sizing: border-box;
}

.viewport-container.desktop .template-iframe {
    height: 100%;
    min-height: calc(100vh - 160px);
}

.viewport-container.tablet .template-iframe {
    height: 768px;
    width: 100%;
    max-width: 100%;
}

.viewport-container.tablet[data-orientation="landscape"] .template-iframe {
    height: 768px;
    width: 100%;
    max-width: 100%;
}

.viewport-container.tablet[data-orientation="portrait"] .template-iframe,
.viewport-container.tablet-portrait .template-iframe {
    height: 1024px;
    width: 100%;
    max-width: 100%;
}

.viewport-container.mobile .template-iframe {
    height: 667px;
    width: 100%;
    max-width: 100%;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .cover-container {
        padding: 40px 20px;
    }

    .main-title {
        font-size: 2.5rem;
    }

    .templates-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .template-header {
        padding: 15px 20px;
        flex-direction: column;
        gap: 15px;
    }

    .device-switcher {
        width: 100%;
        justify-content: center;
    }

    .template-viewer {
        padding: 20px 10px;
        overflow-x: hidden;
    }

    .viewport-container {
        padding: 10px;
        max-width: calc(100vw - 20px);
    }

    .viewport-container.tablet,
    .viewport-container.mobile {
        width: 100%;
        max-width: calc(100vw - 20px);
    }

    .viewport-container.tablet .template-iframe,
    .viewport-container.tablet[data-orientation="landscape"] .template-iframe {
        height: 600px;
        width: 100%;
    }

    .viewport-container.tablet[data-orientation="portrait"] .template-iframe,
    .viewport-container.tablet-portrait .template-iframe {
        height: 800px;
        width: 100%;
    }

    .viewport-container.mobile .template-iframe {
        height: 600px;
        width: 100%;
    }
}

