/* ==========================================================================
   EPP Theme Builder — Premium Admin UI
   Modern, polished admin interface with card grids, modals, animations
   ========================================================================== */

/* ── Design Tokens ───────────────────────────────────────────────────── */

:root {
    /* Spacing scale */
    --eppro-tb-space-xs: 4px;
    --eppro-tb-space-sm: 8px;
    --eppro-tb-space-md: 16px;
    --eppro-tb-space-lg: 24px;
    --eppro-tb-space-xl: 32px;
    --eppro-tb-space-2xl: 48px;
    
    /* Border radius */
    --eppro-tb-radius-sm: 6px;
    --eppro-tb-radius-md: 10px;
    --eppro-tb-radius-lg: 14px;
    --eppro-tb-radius-full: 9999px;
    
    /* Shadows */
    --eppro-tb-shadow-sm: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --eppro-tb-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .08), 0 2px 4px -1px rgba(0, 0, 0, .04);
    --eppro-tb-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .08), 0 4px 6px -2px rgba(0, 0, 0, .04);
    --eppro-tb-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .08), 0 10px 10px -5px rgba(0, 0, 0, .02);
    
    /* Transitions */
    --eppro-tb-transition-base: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --eppro-tb-transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --eppro-tb-transition-bounce: 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Page Container ──────────────────────────────────────────────────── */

.eppro-tb-page {
    background: #f9fafb;
    min-height: 100vh;
    padding: var(--eppro-tb-space-lg) var(--eppro-tb-space-lg) var(--eppro-tb-space-2xl);
}

.eppro-tb-container {
    max-width: 1280px;
    margin: 0 auto;
}

/* ── Page Header ─────────────────────────────────────────────────────── */

.eppro-tb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--eppro-tb-space-xl);
    gap: var(--eppro-tb-space-lg);
    /* Same purple gradient as Settings page */
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #ec4899 100%);
    border-radius: var(--eppro-tb-radius-lg);
    padding: 24px 28px;
    box-shadow: 0 4px 24px rgba(124, 58, 237, .25);
    position: relative;
    overflow: hidden;
}

/* Decorative blobs like Settings page */
.eppro-tb-header::before {
    content: '';
    position: absolute;
    top: -40px;
    right: 80px;
    width: 180px;
    height: 180px;
    background: rgba(255,255,255,.07);
    border-radius: 50%;
    pointer-events: none;
}
.eppro-tb-header::after {
    content: '';
    position: absolute;
    bottom: -30px;
    right: 20px;
    width: 120px;
    height: 120px;
    background: rgba(255,255,255,.05);
    border-radius: 50%;
    pointer-events: none;
}

.eppro-tb-header-left {
    display: flex;
    align-items: center;
    gap: var(--eppro-tb-space-md);
    position: relative;
    z-index: 1;
}

.eppro-tb-logo {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, .18);
    border-radius: var(--eppro-tb-radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
    flex-shrink: 0;
    backdrop-filter: blur(4px);
}

.eppro-tb-logo svg {
    width: 24px;
    height: 24px;
}

.eppro-tb-title-group h1 {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 4px;
    line-height: 1.2;
}

.eppro-tb-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, .8);
    margin: 0;
}

.eppro-tb-version-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, .2);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--eppro-tb-radius-full);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-left: 12px;
    vertical-align: middle;
    backdrop-filter: blur(4px);
}

.eppro-tb-actions {
    display: flex;
    gap: var(--eppro-tb-space-sm);
    position: relative;
    z-index: 1;
}


/* ── Buttons ─────────────────────────────────────────────────────────── */

/* Header buttons on gradient background */
.eppro-tb-header .eppro-tb-btn-secondary {
    background: rgba(255, 255, 255, .18);
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, .35);
    backdrop-filter: blur(4px);
}
.eppro-tb-header .eppro-tb-btn-secondary:hover {
    background: rgba(255, 255, 255, .28);
    border-color: rgba(255, 255, 255, .5);
    box-shadow: none;
}
.eppro-tb-header .eppro-tb-btn-primary {
    background: rgba(255, 255, 255, .95);
    color: #7c3aed;
}
.eppro-tb-header .eppro-tb-btn-primary:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}


.eppro-tb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 20px;
    border-radius: var(--eppro-tb-radius-md);
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border: none;
    cursor: pointer;
    transition: all var(--eppro-tb-transition-base);
    white-space: nowrap;
    text-decoration: none;
}

.eppro-tb-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .1);
}

.eppro-tb-btn-primary {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: #fff;
    box-shadow: var(--eppro-tb-shadow-sm);
}

.eppro-tb-btn-primary:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
    box-shadow: var(--eppro-tb-shadow-md);
    transform: translateY(-1px);
}

.eppro-tb-btn-secondary {
    background: #fff;
    color: #374151;
    border: 1.5px solid #e5e7eb;
}

.eppro-tb-btn-secondary:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    box-shadow: var(--eppro-tb-shadow-sm);
}

.eppro-tb-btn-ghost {
    background: transparent;
    color: #6b7280;
}

.eppro-tb-btn-ghost:hover {
    background: #f3f4f6;
    color: #374151;
}

.eppro-tb-btn-danger {
    background: #fff;
    color: #dc2626;
    border: 1.5px solid #fee2e2;
}

.eppro-tb-btn-danger:hover {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
    box-shadow: var(--eppro-tb-shadow-sm);
}

.eppro-tb-btn-sm {
    height: 34px;
    padding: 0 14px;
    font-size: 13px;
}

.eppro-tb-btn-icon {
    width: 42px;
    padding: 0;
}

.eppro-tb-btn-icon svg,
.eppro-tb-btn-icon .dashicons {
    margin: 0;
}

/* ── Modal System ────────────────────────────────────────────────────── */

.eppro-tb-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    backdrop-filter: blur(4px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--eppro-tb-space-lg);
    opacity: 0;
    animation: eppro-tb-fade-in var(--eppro-tb-transition-smooth) forwards;
}

.eppro-tb-modal {
    background: #fff;
    border-radius: var(--eppro-tb-radius-lg);
    box-shadow: var(--eppro-tb-shadow-xl);
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(.95) translateY(20px);
    animation: eppro-tb-modal-in var(--eppro-tb-transition-bounce) forwards;
}

@keyframes eppro-tb-fade-in {
    to { opacity: 1; }
}

@keyframes eppro-tb-modal-in {
    to { 
        transform: scale(1) translateY(0);
    }
}

.eppro-tb-modal-header {
    padding: var(--eppro-tb-space-lg) var(--eppro-tb-space-xl);
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.eppro-tb-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.eppro-tb-modal-close {
    width: 32px;
    height: 32px;
    border-radius: var(--eppro-tb-radius-sm);
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--eppro-tb-transition-base);
}

.eppro-tb-modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.eppro-tb-modal form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.eppro-tb-modal-body {
    padding: var(--eppro-tb-space-xl);
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.eppro-tb-modal-footer {
    padding: var(--eppro-tb-space-lg) var(--eppro-tb-space-xl);
    border-top: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--eppro-tb-space-sm);
}

/* ── Template Type Selector ──────────────────────────────────────────── */

.eppro-tb-type-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: var(--eppro-tb-space-lg);
}

.eppro-tb-type-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border: 2px solid #e5e7eb;
    border-radius: var(--eppro-tb-radius-md);
    cursor: pointer;
    transition: all var(--eppro-tb-transition-base);
    background: #fff;
}

.eppro-tb-type-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.eppro-tb-type-card:hover {
    border-color: #c4b5fd;
    background: #faf5ff;
    box-shadow: var(--eppro-tb-shadow-sm);
}

.eppro-tb-type-card.selected,
.eppro-tb-type-card:has(input:checked) {
    border-color: #7c3aed;
    background: #faf5ff;
    box-shadow: 0 0 0 3px rgba(124,58,237,.12);
}

.eppro-tb-type-card.selected .eppro-tb-type-icon,
.eppro-tb-type-card:has(input:checked) .eppro-tb-type-icon {
    background: linear-gradient(135deg, #7c3aed 0%, #a78bfa 100%);
    color: #fff;
}

.eppro-tb-type-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--eppro-tb-radius-lg);
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--eppro-tb-space-md);
    font-size: 28px;
    transition: all var(--eppro-tb-transition-smooth);
}

.eppro-tb-type-label {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.eppro-tb-type-desc {
    font-size: 12px;
    color: #6b7280;
    text-align: center;
    line-height: 1.4;
}

/* ── Form Elements ───────────────────────────────────────────────────── */

.eppro-tb-form-group {
    margin-bottom: var(--eppro-tb-space-lg);
}

.eppro-tb-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: var(--eppro-tb-space-sm);
}

.eppro-tb-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: var(--eppro-tb-radius-md);
    font-size: 14px;
    color: #111827;
    background: #fff;
    transition: all var(--eppro-tb-transition-base);
}

.eppro-tb-input:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, .1);
}

.eppro-tb-input::placeholder {
    color: #9ca3af;
}

/* ── Template Cards Grid ─────────────────────────────────────────────── */

.eppro-tb-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--eppro-tb-space-lg);
}

.eppro-tb-template-card {
    background: #fff;
    border-radius: var(--eppro-tb-radius-lg);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    transition: all var(--eppro-tb-transition-smooth);
    cursor: pointer;
}

.eppro-tb-template-card:hover {
    border-color: #c4b5fd;
    box-shadow: var(--eppro-tb-shadow-lg);
    transform: translateY(-2px);
}

.eppro-tb-template-preview {
    height: 140px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.eppro-tb-template-preview::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(124, 58, 237, .04) 100%);
}

.eppro-tb-template-preview-icon {
    font-size: 48px;
    opacity: .3;
}

.eppro-tb-template-body {
    padding: var(--eppro-tb-space-lg);
}

.eppro-tb-template-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--eppro-tb-space-md);
}

.eppro-tb-template-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px;
    line-height: 1.3;
}

.eppro-tb-template-type-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--eppro-tb-radius-full);
    text-transform: uppercase;
    letter-spacing: .04em;
    flex-shrink: 0;
}

.eppro-tb-template-type-badge.eppro-type-header {
    background: #ede9fe;
    color: #7c3aed;
}

.eppro-tb-template-type-badge.eppro-type-footer {
    background: #fef3c7;
    color: #d97706;
}

.eppro-tb-template-type-badge.eppro-type-section {
    background: #cffafe;
    color: #0891b2;
}

.eppro-tb-template-type-badge.eppro-type-single_post {
    background: #dcfce7;
    color: #16a34a;
}

.eppro-tb-template-type-badge.eppro-type-single_page {
    background: #d1fae5;
    color: #059669;
}

.eppro-tb-template-type-badge.eppro-type-archive {
    background: #fce7f3;
    color: #be185d;
}

.eppro-tb-template-type-badge.eppro-type-search {
    background: #e0f2fe;
    color: #0369a1;
}

.eppro-tb-template-type-badge.eppro-type-blog {
    background: #fef9c3;
    color: #a16207;
}

.eppro-tb-template-type-badge.eppro-type-404 {
    background: #fee2e2;
    color: #dc2626;
}

.eppro-tb-template-type-badge.eppro-type-product,
.eppro-tb-template-type-badge.eppro-type-shop,
.eppro-tb-template-type-badge.eppro-type-cart,
.eppro-tb-template-type-badge.eppro-type-checkout,
.eppro-tb-template-type-badge.eppro-type-my_account {
    background: #fdf4ff;
    color: #9333ea;
}

.eppro-tb-template-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--eppro-tb-space-sm);
    margin-bottom: var(--eppro-tb-space-md);
}

.eppro-tb-template-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6b7280;
}

.eppro-tb-template-meta-item .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.eppro-tb-template-conditions {
    font-size: 12px;
    color: #9ca3af;
    margin-bottom: var(--eppro-tb-space-md);
    line-height: 1.5;
}

.eppro-tb-template-actions {
    display: flex;
    gap: var(--eppro-tb-space-sm);
    padding-top: var(--eppro-tb-space-md);
    border-top: 1px solid #f3f4f6;
}

.eppro-tb-template-actions .eppro-tb-btn {
    flex: 1;
}

/* ── Status Badge ────────────────────────────────────────────────────── */

.eppro-tb-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: var(--eppro-tb-radius-full);
}

.eppro-tb-status-badge.active {
    background: #d1fae5;
    color: #059669;
}

.eppro-tb-status-badge.draft {
    background: #f3f4f6;
    color: #6b7280;
}

.eppro-tb-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Empty State ─────────────────────────────────────────────────────── */

.eppro-tb-empty-state {
    background: #fff;
    border-radius: var(--eppro-tb-radius-lg);
    border: 2px dashed #e5e7eb;
    padding: var(--eppro-tb-space-2xl) var(--eppro-tb-space-xl);
    text-align: center;
}

.eppro-tb-empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--eppro-tb-space-lg);
    opacity: .3;
}

.eppro-tb-empty-title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 var(--eppro-tb-space-sm);
}

.eppro-tb-empty-desc {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 var(--eppro-tb-space-xl);
    line-height: 1.6;
}

.eppro-tb-empty-templates {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--eppro-tb-space-md);
    margin: 0 auto var(--eppro-tb-space-xl);
    width: 100%;
    max-width: 900px;
}

@media (max-width: 900px) {
    .eppro-tb-empty-templates {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 600px) {
    .eppro-tb-empty-templates {
        grid-template-columns: repeat(3, 1fr);
    }
}

.eppro-tb-empty-template-card {
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: var(--eppro-tb-radius-md);
    padding: 20px 10px;
    text-align: center;
    transition: border-color .2s, background .2s;
    cursor: default;
}

.eppro-tb-empty-template-card:hover {
    border-color: #7c3aed;
    background: #faf5ff;
}

.eppro-tb-empty-template-icon {
    margin-bottom: var(--eppro-tb-space-sm);
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
}

.eppro-tb-empty-template-icon svg {
    width: 36px;
    height: 36px;
}

.eppro-tb-empty-template-card:hover .eppro-tb-empty-template-icon {
    color: #7c3aed;
}

.eppro-tb-empty-template-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-top: 4px;
}

/* ── Section Headers ─────────────────────────────────────────────────── */

.eppro-tb-section {
    margin-bottom: var(--eppro-tb-space-xl);
}

.eppro-tb-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--eppro-tb-space-lg);
}

.eppro-tb-section-title {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin: 0;
}

.eppro-tb-section-count {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
    margin-left: var(--eppro-tb-space-sm);
}

/* ── Tabs Navigation ─────────────────────────────────────────────────── */

.eppro-tb-tabs {
    display: inline-flex;
    background: #f3f4f6;
    border-radius: var(--eppro-tb-radius-md);
    padding: 4px;
    margin-bottom: var(--eppro-tb-space-lg);
}

.eppro-tb-tab {
    padding: 8px 16px;
    border-radius: var(--eppro-tb-radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--eppro-tb-transition-base);
}

.eppro-tb-tab:hover {
    color: #374151;
}

.eppro-tb-tab.active {
    background: #fff;
    color: #7c3aed;
    box-shadow: var(--eppro-tb-shadow-sm);
}

/* ── Tooltips ────────────────────────────────────────────────────────── */

.eppro-tb-tooltip {
    position: relative;
}

.eppro-tb-tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: #fff;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: var(--eppro-tb-radius-sm);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--eppro-tb-transition-base);
}

.eppro-tb-tooltip:hover::before {
    opacity: 1;
}

/* ── Loading States ──────────────────────────────────────────────────── */

.eppro-tb-skeleton {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: eppro-tb-skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--eppro-tb-radius-sm);
}

@keyframes eppro-tb-skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.eppro-tb-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: eppro-tb-spin .6s linear infinite;
}

@keyframes eppro-tb-spin {
    to { transform: rotate(360deg); }
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .eppro-tb-page {
        padding: var(--eppro-tb-space-md);
    }
    
    .eppro-tb-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .eppro-tb-templates-grid {
        grid-template-columns: 1fr;
    }
    
    .eppro-tb-type-selector {
        grid-template-columns: 1fr;
    }
    
    .eppro-tb-modal-body {
        padding: var(--eppro-tb-space-lg);
    }
}

/* ── Utility Classes ─────────────────────────────────────────────────── */

.eppro-tb-flex { display: flex; }
.eppro-tb-flex-col { flex-direction: column; }
.eppro-tb-items-center { align-items: center; }
.eppro-tb-justify-between { justify-content: space-between; }
.eppro-tb-gap-sm { gap: var(--eppro-tb-space-sm); }
.eppro-tb-gap-md { gap: var(--eppro-tb-space-md); }
.eppro-tb-gap-lg { gap: var(--eppro-tb-space-lg); }
.eppro-tb-mt-lg { margin-top: var(--eppro-tb-space-lg); }
.eppro-tb-mb-lg { margin-bottom: var(--eppro-tb-space-lg); }
.eppro-tb-text-center { text-align: center; }
.eppro-tb-hidden { display: none; }
