/* Templates Page Styles */

/* Hero */
.templates-hero {
    padding: 100px 0 60px;
    background: radial-gradient(1200px 600px at 10% 0%, rgba(245, 158, 11, 0.15), transparent 60%),
        radial-gradient(900px 500px at 90% 10%, rgba(251, 191, 36, 0.16), transparent 60%),
        linear-gradient(180deg, rgba(247, 250, 252, 1) 0%, rgba(255, 255, 255, 1) 100%);
    text-align: center;
}

.templates-hero h1 {
    font-size: 4rem;
    margin-bottom: 20px;
}

.templates-hero p {
    font-size: 1.2rem;
    color: var(--gray);
    line-height: 1.6;
}

/* Glass Feature Pills */
.feature-pills {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 28px 0 10px;
    text-align: center;
}

.feature-pill.glass {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--dark);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
}

.feature-pill.glass:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.feature-pill.glass i {
    width: 18px;
    height: 18px;
    color: var(--primary);
}

/* Categories */
.categories-section {
    padding: 20px 0;
    margin-bottom: 40px;
    border-bottom: 1px solid var(--light-gray);
    position: sticky;
    top: 80px;
    /* Below navbar */
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    z-index: 900;
}

.category-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.category-loading {
    color: var(--gray);
    font-weight: 600;
}

.cat-btn {
    padding: 10px 20px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: rgba(255, 255, 255, 0.9);
    border-radius: 30px;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.3s;
}

.cat-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.cat-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 8px 20px rgba(245, 158, 11, 0.25);
}

/* Templates Grid */
.templates-display {
    padding-bottom: 100px;
}

.templates-carousel {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
}

.templates-track {
    display: flex;
    gap: 24px;
    overflow-x: auto;
    width: 100%;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    padding: 10px 0 24px;
    scrollbar-width: none;
    cursor: grab;
}

.templates-track::-webkit-scrollbar {
    display: none;
}

.templates-track.dragging {
    cursor: grabbing;
}

.template-card {
    background: white;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
    cursor: pointer;
    border: 1px solid rgba(15, 23, 42, 0.08);
    position: relative;
    min-width: 280px;
    max-width: 280px;
    flex: 0 0 auto;
    scroll-snap-align: center;
    transform: translateZ(0) scale(0.98);
}

.template-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(245, 158, 11, 0.2);
}

.template-card::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.28), rgba(251, 191, 36, 0.12), rgba(15, 23, 42, 0.08));
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    z-index: 0;
}

.template-card.is-active {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
    border-color: rgba(245, 158, 11, 0.35);
}

.template-card.is-active::after {
    opacity: 1;
}

.template-card > * {
    position: relative;
    z-index: 1;
}

.templates-empty {
    color: var(--gray);
    padding: 30px;
    width: 100%;
    text-align: center;
}

.templates-nav {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: linear-gradient(145deg, #ffffff, #fff4df);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    color: var(--primary);
    font-size: 1.1rem;
    flex: 0 0 auto;
}

.templates-nav i {
    width: 26px;
    height: 26px;
}

.templates-nav:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.18);
}

.card-image {
    position: relative;
    height: 350px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.template-card:hover .card-image img {
    transform: scale(1.05);
}

.overlay {
    display: none;
}

.card-info {
    padding: 20px;
    text-align: center;
}

.card-info h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.card-info .btn {
    width: 100%;
    justify-content: center;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: none;
    /* Hidden by default */
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.open {
    display: flex;
    animation: fadeIn 0.3s;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.modal-preview {
    background: #f8fafc;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* Changed from center */
    position: sticky;
    /* Added sticky positioning */
    top: 0;
    /* Stick to top */
    height: fit-content;
    /* Ensure it doesn't stretch to full height if not needed */
    align-self: start;
    /* Prevent grid stretching */
}

.modal-preview img {
    max-height: 500px;
    width: auto;
    max-width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.modal-price-tag {
    margin-top: 20px;
    background: var(--dark);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 1.2rem;
}

.modal-form-container {
    padding: 40px;
}

.modal-form-container .form-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-form-container .label {
    font-weight: 600;
    color: #1f2937;
}

.modal-form-container .text-input,
.modal-form-container .text-area-small {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    line-height: 1.4;
    padding: 14px 18px;
}

.modal-form-container .text-input {
    height: 48px;
}

.modal-form-container .text-input:focus,
.modal-form-container .text-area-small:focus {
    outline: none;
    border-color: rgba(245, 158, 11, 0.7);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

.modal-form-container .text-input::placeholder,
.modal-form-container .text-area-small::placeholder {
    color: rgba(74, 85, 104, 0.7);
}

.mini-upload {
    border-radius: 12px;
    background: #f8fafc;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.mini-upload:hover {
    border-color: rgba(245, 158, 11, 0.5);
    background: #ffffff;
}

.order-note {
    margin-top: 12px;
    font-size: 0.85rem;
    color: rgba(74, 85, 104, 0.75);
    line-height: 1.45;
}

.modal-subtitle {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mini-upload {
    border: 2px dashed var(--light-gray);
    padding: 20px;
    text-align: center;
    border-radius: 8px;
    cursor: pointer;
    color: var(--gray);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.9rem;
}

.mini-upload:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.full-width {
    width: 100%;
    justify-content: center;
    margin-top: 20px;
}

.file-list-em {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--gray);
}

/* Variant Selector - Modern Radio Cards */
.variant-selector {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.variant-option {
    display: block;
    cursor: pointer;
}

.variant-option input {
    display: none;
}

.variant-card {
    padding: 14px 18px;
    border: 2px solid var(--border, #e2e8f0);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    background: var(--surface, #ffffff);
}

.variant-card:hover {
    border-color: rgba(245, 158, 11, 0.5);
    background: rgba(245, 158, 11, 0.02);
}

.variant-option input:checked+.variant-card {
    border-color: var(--primary);
    background: rgba(245, 158, 11, 0.08);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12);
}

.variant-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.variant-title {
    font-weight: 600;
    color: var(--dark, #0f172a);
    font-size: 0.95rem;
}

.variant-price {
    font-weight: 700;
    color: var(--primary);
    font-size: 1rem;
}

.variant-info {
    font-size: 0.78rem;
    color: var(--gray, #64748b);
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

/* Promo Code in Modal */
.promo-group-template {
    margin-top: 4px;
}

.promo-input-inline {
    display: flex;
    gap: 10px;
    align-items: center;
}

.templates-nav:focus-visible,
.templates-track:focus-visible,
.modal-backdrop:focus-visible {
    outline: var(--focus-outline);
    outline-offset: 2px;
    box-shadow: var(--focus-ring);
}

.promo-input-inline .text-input {
    flex: 1;
}

.promo-input-inline .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    padding: 10px 16px;
    height: 48px;
}

.promo-input-inline .btn i {
    width: 16px;
    height: 16px;
}

.promo-message {
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

.promo-message.success {
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.promo-message.error {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Promo Success Toast */
.promo-success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
}

.promo-success-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.promo-success-content {
    background: white;
    padding: 40px 50px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.promo-success-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary), #fbbf24);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1.5s infinite;
}

.promo-success-icon i {
    width: 40px;
    height: 40px;
    color: white;
}

.promo-success-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.promo-success-subtitle {
    font-size: 1rem;
    color: var(--gray);
    margin-bottom: 24px;
}

.promo-success-discount {
    display: inline-block;
    background: rgba(16, 185, 129, 0.12);
    color: #059669;
    padding: 8px 20px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 24px;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(245, 158, 11, 0);
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: calc(12px + var(--safe-top)) 0 12px;
    }

    .templates-nav {
        display: none;
    }

    .templates-carousel {
        gap: 0;
    }

    .modal-grid {
        grid-template-columns: 1fr;
    }

    .modal-preview {
        padding: 20px;
        position: relative;
        /* Remove sticky on mobile for better scrolling */
    }

    .modal-preview img {
        max-height: 350px;
    }

    .templates-hero h1 {
        font-size: 2.2rem;
    }

    .templates-hero {
        padding: 60px 0 30px;
    }

    .feature-pills {
        gap: 8px;
        padding: 0 10px;
    }

    .feature-pill.glass {
        padding: 10px 14px;
        font-size: 0.8rem;
    }

    .categories-section {
        top: 60px;
        /* Adjust for smaller navbar */
        padding: 12px 0;
    }

    .category-tabs {
        justify-content: flex-start;
        padding: 0 15px;
        gap: 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
        scroll-snap-type: x mandatory;
    }

    .category-tabs::-webkit-scrollbar {
        display: none;
    }

    .cat-btn {
        flex: 0 0 auto;
        padding: 8px 16px;
        font-size: 0.85rem;
        scroll-snap-align: start;
    }

    .templates-track {
        gap: 16px;
        padding-left: 6px;
        padding-right: 6px;
        scroll-padding: 20px;
    }

    .template-card {
        min-width: 240px;
        max-width: 240px;
    }

    .templates-nav {
        width: 48px;
        height: 48px;
    }

    .card-image {
        height: 320px;
    }

    .modal-content {
        max-width: 100%;
        max-height: 100dvh;
        border-radius: 0;
    }

    .modal-form-container {
        padding: 25px 20px;
    }

    .close-modal {
        top: 15px;
        right: 15px;
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 600px) {
    .promo-input-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .promo-input-inline .btn {
        width: 100%;
        justify-content: center;
    }

    .modal-form-container {
        padding-bottom: calc(30px + var(--safe-bottom, 0px));
    }
}

@media (max-width: 480px) {
    .templates-hero h1 {
        font-size: 1.8rem;
    }

    .card-image {
        height: 280px;
    }

    .templates-track {
        gap: 12px;
    }

    .feature-pills {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .feature-pill.glass {
        width: 100%;
        justify-content: center;
        text-align: center;
    }
}
