/* ===== Templates Page ===== */

.tpl-page-wrap {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 100px 24px 80px;
}

/* Header */
.tpl-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.tpl-page-tabs {
    display: flex;
    gap: 4px;
    background: #f0f2f7;
    border-radius: 14px;
    padding: 4px;
}

.tpl-page-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #5a6a7e;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.tpl-page-tab:hover {
    color: #12294B;
    text-decoration: none;
}

.tpl-page-tab--active {
    background: #ffffff;
    color: #12294B;
    box-shadow: 0 1px 4px rgba(18, 41, 75, 0.1);
}

.tpl-page-tab svg {
    flex-shrink: 0;
    opacity: 0.5;
}

.tpl-page-tab--active svg {
    opacity: 1;
}

/* Add button */
.tpl-add-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--color-blue-dark, #12294B);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
}

.tpl-add-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Folders — override old styles */
.tpl-page-wrap .folders-all {
    background: #ffffff;
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 2px 8px rgba(18, 41, 75, 0.04);
    border: 1px solid rgba(18, 41, 75, 0.06);
    margin-bottom: 20px;
}

.tpl-page-wrap .folder {
    width: auto;
    min-width: unset;
    padding: 8px 18px;
    border-radius: 10px;
    border: 1px solid #e0e6ee;
    background: #f8f9fb;
    font-size: 14px;
    font-weight: 500;
    color: #3a4a5e;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.tpl-page-wrap .folder:hover {
    border-color: var(--color-blue-dark, #3657CD);
    color: var(--color-blue-dark, #3657CD);
}

.tpl-page-wrap .folder-active {
    background: var(--color-blue-dark, #12294B);
    border-color: var(--color-blue-dark, #12294B);
    color: #ffffff;
}

/* Table — override custom-table */
.tpl-page-wrap .custom-table {
    width: 100%;
    border: none;
    border-collapse: separate;
    border-spacing: 0;
    background: #ffffff;
    border-radius: 16px;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(18, 41, 75, 0.04);
    border: 1px solid rgba(18, 41, 75, 0.06);
    padding: 0 !important;
}

/* Border-radius on corner cells (replaces overflow:hidden) */
.tpl-page-wrap .custom-table th:first-child { border-top-left-radius: 16px; }
.tpl-page-wrap .custom-table th:last-child { border-top-right-radius: 16px; }
.tpl-page-wrap .custom-table > tbody > tr:last-child > td:first-child { border-bottom-left-radius: 16px; }
.tpl-page-wrap .custom-table > tbody > tr:last-child > td:last-child { border-bottom-right-radius: 16px; }

.tpl-page-wrap .custom-table th {
    background: #f5f7fa;
    padding: 14px 20px;
    font-weight: 600;
    font-size: 13px;
    color: #12294B;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid #e0e6ee;
}

.tpl-page-wrap .custom-table > tbody > tr > td {
    padding: 14px 20px;
    height: auto;
    font-size: 14px;
    color: #3a4a5e;
    border-bottom: 1px solid #f0f2f7;
}

.tpl-page-wrap .custom-table tr {
    border: none;
    transition: background 0.15s;
}

.tpl-page-wrap .custom-table tbody tr:hover {
    background: #f8f9fb;
}

.tpl-page-wrap .custom-table thead {
    border: none;
    height: auto;
}

.tpl-page-wrap .sortable-table-header {
    cursor: pointer;
    user-select: none;
}

.tpl-page-wrap .sortable-table-header:hover {
    color: var(--color-blue-dark, #3657CD);
    text-decoration: none;
}

/* Template badges */
.tpl-page-wrap .template-badge-parent {
    border: none;
    background: #e3f2fd;
    color: #1565c0;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.tpl-page-wrap .template-badge-child {
    border: none;
    background: #f0f2f7;
    color: #5a6a7e;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

/* Templates table/cards visibility toggle at 768px */
@media (max-width: 768px) {
    .tpl-hide-mobile {
        display: none !important;
    }
}
@media (min-width: 769px) {
    .tpl-hide-desktop {
        display: none !important;
    }
}

/* ===== Mobile template cards ===== */
.tpl-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.tpl-mcard {
    background: #fff;
    border-radius: 14px;
    border: 1px solid rgba(18, 41, 75, 0.06);
    box-shadow: 0 2px 8px rgba(18, 41, 75, 0.04);
    padding: 14px 16px;
}

.tpl-mcard-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.tpl-mcard-status {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
}

.tpl-mcard-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.tpl-mcard-status--active {
    background: #e8f5e9;
    color: #2e7d32;
}
.tpl-mcard-status--active .tpl-mcard-status-dot {
    background: #2e7d32;
}

.tpl-mcard-status--moderation {
    background: #fff3e0;
    color: #e65100;
}
.tpl-mcard-status--moderation .tpl-mcard-status-dot {
    background: #e65100;
}

.tpl-mcard-sub-badge {
    font-size: 11px;
    font-weight: 600;
    color: #3657CD;
    background: #eef1f8;
    border: none;
    border-radius: 6px;
    padding: 3px 10px;
    cursor: pointer;
    transition: background 0.15s;
}

.tpl-mcard-sub-badge:hover {
    background: #dde3f2;
}

.tpl-mcard-title {
    margin-bottom: 6px;
}

.tpl-mcard-link {
    font-size: 15px;
    font-weight: 600;
    color: #12294B;
    text-decoration: none;
    cursor: pointer;
    line-height: 1.35;
}

.tpl-mcard-link:hover {
    color: #3657CD;
}

.tpl-mcard-name-muted {
    font-size: 15px;
    font-weight: 600;
    color: #9aa5b4;
    line-height: 1.35;
}

.tpl-mcard-desc {
    font-size: 13px;
    color: #5a6a7e;
    margin-bottom: 8px;
    line-height: 1.4;
}

.tpl-mcard-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #f0f2f7;
}

.tpl-mcard-date {
    font-size: 12px;
    color: #9aa5b4;
    font-weight: 500;
    white-space: nowrap;
}

.tpl-mcard-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.tpl-mcard-autosign-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 8px;
}

.tpl-mcard-autosign {
    margin-left: auto;
}

/* Icon buttons */
.tpl-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    text-decoration: none;
    flex-shrink: 0;
}

.tpl-icon-btn--default {
    color: #5a6a7e;
    background: #f0f2f7;
}

.tpl-icon-btn--default:hover {
    background: #e0e6ee;
    color: #12294B;
}

.tpl-icon-btn--danger {
    color: #d32f2f;
    background: #fce4ec;
}

.tpl-icon-btn--danger:hover {
    background: #ef9a9a;
    color: #b71c1c;
}

/* Autosign */
.tpl-autosign-label {
    font-size: 13px;
    color: #5a6a7e;
    margin-top: 2px;
    cursor: pointer;
}

.tpl-autosign-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--color-blue-dark, #12294B);
    cursor: pointer;
}

/* ===== Actions dropdown ===== */
.tpl-actions-dropdown {
    position: relative;
}

.tpl-actions-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #5a6a7e;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.tpl-actions-trigger:hover {
    background: #f0f2f7;
    color: #12294B;
}

.tpl-actions-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    min-width: 200px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(18, 41, 75, 0.12), 0 2px 8px rgba(18, 41, 75, 0.06);
    border: 1px solid rgba(18, 41, 75, 0.06);
    padding: 6px;
    animation: tplMenuFadeIn 0.15s ease;
}

@keyframes tplMenuFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.tpl-actions-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #3a4a5e;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    text-decoration: none;
    white-space: nowrap;
}

.tpl-actions-item:hover {
    background: #f0f2f7;
    color: #12294B;
    text-decoration: none;
}

.tpl-actions-item svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.tpl-actions-item:hover svg {
    opacity: 1;
}

.tpl-actions-divider {
    height: 1px;
    background: #f0f2f7;
    margin: 4px 6px;
}

.tpl-actions-item--danger {
    color: #d32f2f;
}

.tpl-actions-item--danger:hover {
    background: #fce4ec;
    color: #b71c1c;
}

.tpl-actions-item--danger svg {
    opacity: 0.8;
}

/* Clipboard tooltip inside dropdown */
.tpl-actions-menu .clipboard-tooltip {
    position: absolute;
    bottom: -30px;
    right: 0;
    background: #12294B;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.tpl-actions-menu .clipboard-tooltip.visible {
    opacity: 1;
}

/* Disabled autosign */
.tpl-autosign-disabled {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 0.3;
    cursor: pointer;
}

.tpl-autosign-disabled input {
    pointer-events: none;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .tpl-page-wrap {
        padding: 90px 16px 48px;
    }

    .tpl-page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .tpl-page-tabs {
        width: 100%;
    }

    .tpl-page-tab {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
        font-size: 13px;
    }

    .tpl-add-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Button row */
.tpl-btn-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tpl-btn-row--center {
    justify-content: center;
    gap: 10px;
}

/* Buy template button */
.tpl-buy-btn {
    padding: 8px 16px;
    font-size: 13px;
    width: auto;
}

/* Paid templates action cell */
.tpl-table-action-cell {
    width: 1px;
    white-space: nowrap;
    text-align: right;
}
