/* --------------------------------------------------------------------------
   Template Cards - Terminal Brutalism
   -------------------------------------------------------------------------- */
.template-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: var(--space-5);
}

.template-card {
    background: var(--bg-darkest);
    border: 2px solid var(--border-medium);
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.1);
    transition: all 0.15s ease;
}

.template-card:hover {
    border-color: var(--accent-primary);
}

.template-card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
}

.template-card-title {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 0;
}

.template-card-title svg {
    flex-shrink: 0;
    color: var(--accent-primary);
}

.template-card-title h3 {
    font-family: var(--font-sans);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-card-badges {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

.template-version-badge {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-primary);
    background: rgba(245, 166, 35, 0.2);
    padding: 0.125rem 0.5rem;
    border: none;
    border-radius: 0.375rem;
}

.template-status-badge {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--success);
    background: rgba(34, 197, 94, 0.2);
    padding: 0.125rem 0.5rem;
    border: none;
    border-radius: 0.375rem;
}

.template-card-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.template-card-preview {
    height: 180px;
    background: var(--bg-medium);
    border-bottom: 1px solid var(--border-subtle);
    overflow: hidden;
    position: relative;
}

.template-card-preview iframe {
    transform: scale(0.4);
    transform-origin: top left;
    width: 250%;
    height: 250%;
    pointer-events: none;
}

.template-no-preview {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    color: var(--text-dim);
}

.template-no-preview svg {
    opacity: 0.5;
}

.template-no-preview span {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
}

.template-code-preview {
    height: 100%;
    overflow: hidden;
    background: var(--bg-darkest);
    padding: var(--space-3);
}

.template-code-preview pre {
    margin: 0;
    height: 100%;
    overflow: hidden;
}

.template-code-preview code {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-dim);
    white-space: pre-wrap;
    word-break: break-all;
}

.template-card-footer {
    padding: var(--space-4) var(--space-5);
    background: var(--bg-dark);
}

.template-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}

.template-date,
.template-vars-count {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.template-date svg,
.template-vars-count svg {
    color: var(--text-dim);
}

.template-variables {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.template-var-tag {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: rgba(160, 160, 160, 0.2);
    padding: 0.125rem 0.5rem;
    border: none;
    border-radius: 0.375rem;
}

.template-card-actions {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-subtle);
}

/* Icon buttons (reusable) */
.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border-medium);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-icon-danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border-color: var(--error);
}

/* --------------------------------------------------------------------------
   Template Preview Modal - Full Viewport Takeover
   -------------------------------------------------------------------------- */

.template-preview-modal {
    background: rgba(0, 0, 0, 0.92);
}

.template-preview-container {
    width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.template-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 48px;
    min-height: 48px;
    background: #08090b;
    border-bottom: 1px solid #2a2d32;
}

.template-preview-name {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    color: #f5a623;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.template-preview-close {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid #2a2d32;
    color: #6b7280;
    padding: 4px 12px;
    cursor: pointer;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    transition: all 0.15s;
}

.template-preview-close span {
    font-size: 0.8rem;
    opacity: 0.6;
}

.template-preview-close:hover {
    color: #fff;
    border-color: #f5a623;
}

.template-preview-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    justify-content: center;
    background: #111214;
}

.template-preview-body iframe {
    width: 100%;
    max-width: 700px;
    height: 100%;
    border: none;
    background: #fff;
    box-shadow: 0 0 80px rgba(0, 0, 0, 0.5);
}
