/**
 * Formera Admin Styles
 */

/* Variables scoped to Formera plugin container */
.ds-app-container,
.gf-builder-wrap {
    /* Primary Color Palette */
    --ds-primary: #673ab7;
    --ds-primary-hover: #5e35b1;
    --ds-primary-dark: #512da8;
    --ds-primary-glow: rgba(103, 58, 183, 0.15);
    --ds-primary-soft: #ede7f6;

    /* Neutrals & UI Colors */
    --ds-secondary: #202124;
    --ds-text: #3c4043;
    --ds-text-light: #5f6368;
    --ds-bg: #f1f3f4;
    --ds-white: #FFFFFF;
    --ds-border: #dadce0;
    --ds-divider: #e8eaed;

    /* Functional Colors */
    --ds-success: #34a853;
    --ds-error: #ea4335;
    --ds-warning: #fbbc04;
    --ds-info: #4285f4;
    --ds-pro: #673ab7;

    /* Spacing & Borders */
    --ds-radius-sm: 8px;
    --ds-radius-md: 8px;
    --ds-radius-lg: 8px;
    --ds-shadow-sm: 0 1px 2px 0 rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    --ds-shadow: 0 1px 3px 0 rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
    --ds-shadow-lg: 0 1px 3px 0 rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);

    --ds-sidebar-width: 260px;

    /* Typography */
    --ds-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Entrance Animation */
@keyframes dsFadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes dsSlideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes dsPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.ds-animate {
    animation: dsFadeUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Layout Components */
.ds-app-container {
    display: flex;
    min-height: calc(100vh - 32px);
    font-family: var(--ds-font-family);
    color: var(--ds-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.ds-sidebar {
    width: var(--ds-sidebar-width);
    background: var(--ds-white);
    padding: 24px 12px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 32px;
    height: calc(100vh - 32px);
    z-index: 100;
    border-right: 1px solid var(--ds-border);
}

.ds-sidebar-logo {
    font-family: var(--ds-font-family);
    font-size: 20px;
    font-weight: 500;
    color: var(--ds-text);
    margin-bottom: 32px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ds-sidebar-logo svg {
    color: var(--ds-primary);
}

.ds-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 0 24px 24px 0;
    color: var(--ds-text);
    text-decoration: none;
    font-weight: 500;
    margin-bottom: 2px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    margin-left: -12px;
    padding-left: 28px;
}

.ds-nav-item:hover {
    background: var(--ds-bg);
    color: var(--ds-text);
}

.ds-nav-item.active {
    background: var(--ds-primary-soft);
    color: var(--ds-primary);
    font-weight: 500;
}

.ds-nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    flex-shrink: 0;
}

.ds-main-content {
    flex: 1;
    padding: 32px 48px;
    max-width: 1100px;
}

/* Page Header */
.ds-top-bar {
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.ds-title {
    font-family: var(--ds-font-family);
    font-size: 24px;
    font-weight: 400;
    color: var(--ds-secondary);
    margin: 0;
    letter-spacing: 0;
}

/* Cards */
.ds-card {
    background: var(--ds-white);
    border-radius: var(--ds-radius-md);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--ds-border);
    box-shadow: none;
    transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ds-card:hover {
    box-shadow: var(--ds-shadow-sm);
}

/* Stats Widgets */
.ds-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.ds-stat-card {
    background: var(--ds-white);
    padding: 24px;
    border-radius: var(--ds-radius-md);
    border: 1px solid var(--ds-border);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ds-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--ds-primary);
    opacity: 0;
    transition: opacity 0.2s;
}

.ds-stat-card:hover::before {
    opacity: 1;
}

.ds-stat-card:hover {
    box-shadow: var(--ds-shadow);
}

.ds-stat-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--ds-text-light);
    margin-bottom: 8px;
}

.ds-stat-value {
    font-size: 36px;
    font-weight: 400;
    color: var(--ds-secondary);
    font-family: var(--ds-font-family);
}

/* Buttons */
.ds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    text-decoration: none !important;
    font-family: var(--ds-font-family);
    letter-spacing: 0.25px;
}

.ds-btn-primary {
    background: var(--ds-primary);
    color: var(--ds-white);
    box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
}

.ds-btn-primary:hover {
    background: var(--ds-primary-hover);
    box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
    color: var(--ds-white);
}

.ds-btn-primary:active {
    background: var(--ds-primary-dark);
}

.ds-btn-secondary {
    background: var(--ds-white);
    color: var(--ds-primary);
    border: 1px solid var(--ds-border);
}

.ds-btn-secondary:hover {
    background: var(--ds-primary-soft);
    border-color: var(--ds-primary-soft);
    color: var(--ds-primary);
}

.ds-btn-danger-solid {
    background: var(--ds-error);
    color: var(--ds-white);
}

.ds-btn-danger-solid:hover {
    background: #d93025;
    box-shadow: 0 1px 3px rgba(60,64,67,.3), 0 4px 8px 3px rgba(60,64,67,.15);
}

/* Outlined button variant */
.ds-btn-outlined {
    background: transparent;
    color: var(--ds-primary);
    border: 1px solid var(--ds-border);
}

.ds-btn-outlined:hover {
    background: var(--ds-primary-soft);
    border-color: var(--ds-primary);
}

/* Tables */
.ds-table-card {
    padding: 0;
    overflow: hidden;
}

.ds-table-container {
    overflow-x: auto;
}

.ds-table {
    width: 100%;
    border-collapse: collapse;
}

.ds-table th {
    background: var(--ds-bg);
    padding: 14px 24px;
    text-align: left;
    font-size: 12px;
    font-weight: 500;
    color: var(--ds-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--ds-border);
}

.ds-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--ds-divider);
    vertical-align: middle;
    font-size: 14px;
    color: var(--ds-text);
}

.ds-table tr {
    transition: background 0.15s;
}

.ds-table tbody tr:hover {
    background: #f8f9fa;
}

.ds-table tbody tr:last-child td {
    border-bottom: none;
}

.ds-row-actions {
    opacity: 0;
    transition: all 0.2s ease;
}

.ds-table tr:hover .ds-row-actions {
    opacity: 1;
}

.ds-badge {
    display: inline-flex;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.ds-badge-indigo {
    background: var(--ds-primary-soft);
    color: var(--ds-primary);
}

.ds-badge-success {
    background: #e6f4ea;
    color: #137333;
}

.ds-badge-error {
    background: #fce8e6;
    color: #c5221f;
}

.ds-badge-warning {
    background: #fef7e0;
    color: #b06000;
}

.ds-badge-pro {
    background: var(--ds-primary-soft);
    color: var(--ds-primary);
}

/* Inputs */
.ds-input-field {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--ds-border);
    border-radius: 4px;
    font-size: 14px;
    color: var(--ds-text);
    background: var(--ds-white);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--ds-font-family);
}

.ds-input-field:hover {
    border-color: var(--ds-text-light);
}

.ds-input-field:focus {
    outline: none;
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 2px var(--ds-primary-soft);
}

.ds-label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--ds-text);
}

/* Builder Items */
.ds-q-item {
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    margin-bottom: 12px;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ds-q-item:hover {
    box-shadow: var(--ds-shadow-sm);
}

.ds-q-item.ds-focused {
    border-left: 4px solid var(--ds-primary);
}

.ds-q-item-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.ds-q-item-body {
    padding: 24px;
    border-top: 1px solid var(--ds-divider);
    background: #fafafa;
}

/* Custom Toggles - Google Style */
.ds-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 14px;
}

.ds-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ds-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,.26);
    transition: .2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 14px;
}

.ds-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: -2px;
    top: -3px;
    background-color: #fafafa;
    transition: .2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,.4);
}

.ds-toggle input:checked+.ds-toggle-slider {
    background-color: rgba(103, 58, 183, 0.5);
}

.ds-toggle input:checked+.ds-toggle-slider:before {
    transform: translateX(20px);
    background-color: var(--ds-primary);
}

.rotated {
    transform: rotate(180deg);
}

/* Modal - Google Style */
.ds-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
}

.ds-modal-content {
    background: var(--ds-white);
    padding: 24px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    text-align: left;
    box-shadow: var(--ds-shadow-lg);
    animation: dsFadeUp 0.2s ease-out;
}

.ds-modal-content h3 {
    font-size: 18px;
    font-weight: 500;
    color: var(--ds-secondary);
    margin: 0 0 8px;
}

.ds-modal-icon {
    width: 48px;
    height: 48px;
    background: #fce8e6;
    color: var(--ds-error);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.formera-create-modal-content {
    background: var(--ds-white);
    border-radius: 10px;
    width: min(1120px, 95vw);
    max-height: 88vh;
    box-shadow: var(--ds-shadow-lg);
    animation: dsFadeUp 0.2s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.formera-create-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--ds-divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.formera-create-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--ds-secondary);
}

.formera-create-modal-close {
    border: none;
    background: transparent;
    color: var(--ds-text-light);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.formera-create-modal-close:hover {
    background: var(--ds-bg);
    color: var(--ds-secondary);
}

.formera-create-modal-body {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.formera-create-modal-sidebar {
    border-right: 1px solid var(--ds-divider);
    padding: 16px;
    background: var(--ds-bg);
    overflow-y: auto;
}

.formera-create-modal-search input {
    width: 100%;
    border: 1px solid var(--ds-border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    outline: none;
}

.formera-create-modal-search input:focus {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px rgba(103, 58, 183, 0.1);
}

.formera-create-modal-cats {
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.formera-create-modal-cat {
    border: none;
    background: transparent;
    color: var(--ds-text);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.formera-create-modal-cat span {
    color: var(--ds-text-light);
    font-size: 13px;
}

.formera-create-modal-cat.active {
    background: var(--ds-primary-soft);
    color: var(--ds-primary);
}

.formera-create-modal-main {
    padding: 16px;
    overflow-y: auto;
}

.formera-create-modal-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.formera-create-modal-card {
    border: 1px solid var(--ds-divider);
    border-radius: 10px;
    overflow: hidden;
    background: var(--ds-white);
    display: flex;
    flex-direction: column;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.formera-create-modal-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--ds-shadow-md);
}

.formera-create-modal-card-head {
    min-height: 88px;
    padding: 14px;
    background: #f5f3ff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.formera-create-modal-blank-icon,
.formera-create-modal-icon-wrap {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.formera-create-modal-blank-icon {
    background: var(--ds-primary-soft);
    color: var(--ds-primary);
}

.formera-create-modal-icon-wrap {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.formera-create-modal-icon-wrap svg {
    width: 22px;
    height: 22px;
}

.formera-create-modal-fields {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
    padding: 3px 8px;
}

.formera-create-modal-card-body {
    padding: 14px;
}

.formera-create-modal-card-body h4 {
    margin: 0 0 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--ds-secondary);
}

.formera-create-modal-card-body p {
    margin: 0;
    font-size: 13px;
    color: var(--ds-text-light);
    line-height: 1.45;
}

.formera-create-modal-card-footer {
    margin-top: auto;
    padding: 12px 14px;
    border-top: 1px solid var(--ds-divider);
}

.formera-create-modal-card-footer .ds-btn {
    width: 100%;
    justify-content: center;
}

.formera-create-modal-empty {
    padding: 24px;
    text-align: center;
    color: var(--ds-text-light);
    font-size: 14px;
}

.formera-create-modal-footer {
    border-top: 1px solid var(--ds-divider);
    padding: 12px 16px;
    display: flex;
    justify-content: flex-end;
}

@media (max-width: 1024px) {
    .formera-create-modal-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 768px) {
    .formera-create-modal-body {
        grid-template-columns: 1fr;
    }

    .formera-create-modal-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--ds-divider);
    }

    .formera-create-modal-grid {
        grid-template-columns: 1fr;
    }
}

/* Empty State */
.ds-empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--ds-text-light);
}

.ds-empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--ds-border);
    margin-bottom: 16px;
}

.ds-empty-state h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--ds-text);
    margin: 0 0 8px;
}

.ds-empty-state p {
    font-size: 14px;
    margin: 0;
}

/* Shortcode display */
.ds-shortcode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--ds-bg);
    border-radius: 4px;
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 12px;
    color: var(--ds-text);
    border: 1px solid var(--ds-border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.ds-shortcode:hover {
    background: var(--ds-divider);
    border-color: var(--ds-primary);
}

.ds-shortcode code {
    background: none;
    padding: 0;
    font-size: 12px;
    color: inherit;
}

.ds-copy-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--ds-text-light);
    border-radius: 3px;
    transition: color 0.2s ease;
}

.ds-copy-btn:hover {
    color: var(--ds-primary);
}

.ds-copy-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.ds-shortcode.ds-copied {
    border-color: var(--ds-success);
    background: #e6f4ea;
}

.ds-shortcode.ds-copied .ds-copy-btn {
    color: var(--ds-success);
}

/* Responsive */
@media (max-width: 1024px) {
    .ds-sidebar {
        display: none;
    }

    .ds-main-content {
        padding: 24px 16px;
    }
    
    .ds-top-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .ds-stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .ds-table th,
    .ds-table td {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .ds-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .ds-card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .ds-main-content {
        padding: 16px 12px;
    }
    
    .ds-title {
        font-size: 20px;
    }
    
    .ds-stat-value {
        font-size: 28px;
    }
}

/* Chevron rotation for settings toggle */
.gf-chevron.gf-rotated {
    transform: rotate(180deg) !important;
}

/* =============================================
   TEMPLATES PAGE STYLES
   ============================================= */

/* Search Bar */
.formera-tpl-search-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--ds-white);
    border: 1.5px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    padding: 12px 16px;
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.formera-tpl-search-bar:focus-within {
    border-color: var(--ds-primary);
    box-shadow: 0 0 0 3px var(--ds-primary-glow);
}

.formera-tpl-search-bar input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    font-family: var(--ds-font-family);
    color: var(--ds-text);
    width: 100%;
}

.formera-tpl-search-bar input::placeholder {
    color: var(--ds-text-light);
}

/* Category Tabs */
.formera-tpl-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.formera-tpl-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1.5px solid var(--ds-border);
    border-radius: 100px;
    background: var(--ds-white);
    color: var(--ds-text-light);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--ds-font-family);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.formera-tpl-tab svg {
    width: 16px;
    height: 16px;
}

.formera-tpl-tab:hover {
    border-color: var(--ds-primary);
    color: var(--ds-primary);
    background: var(--ds-primary-soft);
}

.formera-tpl-tab.active {
    background: var(--ds-primary);
    color: white;
    border-color: var(--ds-primary);
}

.formera-tpl-tab.active svg {
    color: white;
}

/* Templates Grid */
.formera-tpl-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* Template Card */
.formera-tpl-card {
    background: var(--ds-white);
    border-radius: var(--ds-radius-md);
    border: 1.5px solid var(--ds-border);
    overflow: hidden;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.formera-tpl-card:hover {
    border-color: var(--ds-primary);
    box-shadow: var(--ds-shadow);
    transform: translateY(-2px);
}

.formera-tpl-card-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
}

.formera-tpl-card-icon {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.formera-tpl-card-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.formera-tpl-card-count {
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 100px;
    backdrop-filter: blur(4px);
}

.formera-tpl-card-body {
    padding: 20px;
    flex: 1;
}

.formera-tpl-card-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ds-secondary);
}

.formera-tpl-card-desc {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--ds-text-light);
    line-height: 1.5;
}

.formera-tpl-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.formera-tpl-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--ds-primary-soft);
    color: var(--ds-primary);
}

.formera-tpl-card-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--ds-divider);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Click hint text in card footer */
.formera-tpl-click-hint {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--ds-text-light);
    opacity: 0;
    transition: opacity 0.2s;
}

.formera-tpl-card:hover .formera-tpl-click-hint {
    opacity: 1;
}

.formera-tpl-open-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ds-primary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* Template Preview Modal - dedicated overlay (avoids stacking context issues) */
.formera-tpl-overlay {
    display: none;
    position: fixed;
    z-index: 9999999;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

/* Template Preview Modal */
.formera-tpl-modal-content {
    background: var(--ds-white);
    max-width: 600px;
    width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    border-radius: var(--ds-radius-lg);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2);
    animation: dsFadeUp 0.25s ease-out;
}

.formera-tpl-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--ds-divider);
    flex-shrink: 0;
}

.formera-tpl-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.formera-tpl-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--ds-divider);
    flex-shrink: 0;
}

/* Preview question items */
.formera-tpl-preview-q {
    padding: 16px;
    background: var(--ds-bg);
    border-radius: var(--ds-radius-sm);
    margin-bottom: 12px;
}

.formera-tpl-preview-q:last-child {
    margin-bottom: 0;
}

.formera-tpl-preview-q-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--ds-secondary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.formera-tpl-preview-q-title .formera-tpl-required {
    color: var(--ds-error);
    font-weight: 600;
}

.formera-tpl-preview-q-type {
    font-size: 12px;
    color: var(--ds-text-light);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.formera-tpl-preview-opts {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.formera-tpl-preview-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--ds-text);
}

.formera-tpl-preview-opt-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--ds-border);
    flex-shrink: 0;
}

.formera-tpl-preview-opt-icon.checkbox {
    border-radius: 3px;
}

.formera-tpl-preview-field {
    height: 36px;
    border-bottom: 1.5px solid var(--ds-border);
    width: 60%;
}

.formera-tpl-preview-field.textarea {
    height: 64px;
    width: 100%;
    border: 1.5px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
}

/* Empty state for filtered templates */
.formera-tpl-empty {
    text-align: center;
    padding: 48px 24px;
}

/* Animation for cards */
.formera-tpl-card {
    animation: dsFadeUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.formera-tpl-card:nth-child(2) { animation-delay: 0.05s; }
.formera-tpl-card:nth-child(3) { animation-delay: 0.1s; }
.formera-tpl-card:nth-child(4) { animation-delay: 0.15s; }
.formera-tpl-card:nth-child(5) { animation-delay: 0.2s; }
.formera-tpl-card:nth-child(6) { animation-delay: 0.25s; }
.formera-tpl-card:nth-child(7) { animation-delay: 0.3s; }
.formera-tpl-card:nth-child(8) { animation-delay: 0.35s; }
.formera-tpl-card:nth-child(9) { animation-delay: 0.4s; }

/* Responsive */
@media (max-width: 768px) {
    .formera-tpl-grid {
        grid-template-columns: 1fr;
    }
    
    .formera-tpl-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }
    
    .formera-tpl-modal-content {
        width: 95vw;
        max-height: 90vh;
    }
}