/* Templates Page Styles - Matches Letters Page Design */

.templates-page {
    max-width: 2500px;
    margin: 0 auto;
    outline: none;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.page-title h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-title p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.page-actions {
    display: flex;
    gap: 12px;
}

/* Status Tabs */
.status-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.status-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
}

.status-tab:hover {
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.5);
}

.status-tab.active {
    background: white;
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tab-count {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--border-primary);
    color: var(--text-muted);
}

.status-tab.active .tab-count {
    background: var(--color-primary-bg);
    color: var(--color-primary);
}

.tab-count.highlight {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
    font-weight: 600;
}

/* Filters Bar */
.filters-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 16px;
}

.filters-left {
    display: flex;
    gap: 12px;
}

.filters-right {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

.filter-dropdown {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
}

.filter-dropdown i {
    color: var(--text-placeholder);
    font-size: 14px;
}

.filter-dropdown select {
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    padding-right: 20px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.5 4.5l3.5 3.5 3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0 center;
}

.filter-dropdown select:focus {
    outline: none;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: white;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    min-width: 264px;
}

.search-box i {
    color: var(--text-placeholder);
    font-size: 14px;
}

.search-box input {
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--text-secondary);
    width: 100%;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-placeholder);
}

/* Templates Table */
.templates-table {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border-primary);
    overflow: visible;
}

.templates-page .table-header {
    display: grid;
    grid-template-columns: 40px minmax(180px, 2fr) minmax(80px, 1fr) 90px minmax(100px, 140px) minmax(120px, 160px) 90px 100px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-radius: 16px 16px 0 0;
    gap: 8px;
}

.templates-page .template-row {
    display: grid;
    grid-template-columns: 40px minmax(180px, 2fr) minmax(80px, 1fr) 90px minmax(100px, 140px) minmax(120px, 160px) 90px 100px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--bg-tertiary);
    align-items: center;
    border-left: 4px solid transparent;
    transition: background 0.2s ease, border-left-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    gap: 8px;
}

.template-row:hover {
    background: var(--bg-secondary);
    border-left-color: var(--color-warning);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 1;
}

.template-row:last-child {
    border-bottom: none;
}

.template-row.selected {
    background: var(--color-primary-bg-subtle);
    border-left-color: var(--color-warning);
}

/* Checkbox */
.col-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox {
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-faint);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkbox:hover {
    border-color: var(--text-placeholder);
}

.checkbox.checked {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.checkbox.checked::after {
    content: "";
    width: 10px;
    height: 6px;
    border-left: 2px solid white;
    border-bottom: 2px solid white;
    transform: rotate(-45deg) translate(1px, -1px);
}

/* Template Info */
.template-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.template-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.template-name span {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.template-name a,
.template-name a:link,
.template-name a:visited,
.template-name a:active,
.template-name .template-name-link,
.template-name .template-name-link:link,
.template-name .template-name-link:visited,
.template-name .template-name-link:active {
    font-size: 14px !important;
    font-weight: 500 !important;
    color: var(--text-primary) !important;
    text-decoration: none !important;
    transition: color 0.15s;
}

.template-name a:hover,
.template-name .template-name-link:hover {
    color: var(--color-primary) !important;
}

.template-description {
    font-size: 12px;
    color: var(--text-placeholder);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 400px;
}

/* Type Badge */
.type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--color-primary-bg);
    color: var(--color-info-text);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-badge.active {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.status-badge.inactive {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.status-badge.draft {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.status-badge.pending {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.status-badge.rejected {
    background: var(--color-danger-bg);
    color: var(--color-danger-dark);
}

/* Status Badges Container */
.status-badges {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

/* Approval Badge */
.approval-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.approval-badge.draft {
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
}

.approval-badge.pending {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.approval-badge.approved {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.approval-badge.rejected {
    background: var(--color-danger-bg);
    color: var(--color-danger-dark);
}

/* Approver Column */
.col-approver {
    display: flex;
    align-items: center;
    justify-content: center;
}

.approver-bubble {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    text-transform: uppercase;
    position: relative;
}

.approver-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.approver-bubble.approved {
    background: linear-gradient(135deg, #22c55e, #16a34a);
}

.approver-bubble.pending {
    background: linear-gradient(135deg, var(--color-warning), #d97706);
}

/* Custom tooltip for approver bubble */
.approver-bubble[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-4px);
    background: #1f2937;
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    transition-delay: 0s;
    z-index: 1000;
    pointer-events: none;
    text-transform: none;
}

.approver-bubble[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    border: 6px solid transparent;
    border-top-color: #1f2937;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    transition-delay: 0s;
    z-index: 1000;
    pointer-events: none;
}

.approver-bubble[data-tooltip]:hover::after,
.approver-bubble[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transition-delay: 0.15s;
}

.no-approver {
    color: var(--text-placeholder);
    font-size: 16px;
}

/* Date Cell */
.date-cell {
    font-size: 13px;
    color: var(--text-secondary);
}

.date-cell .time {
    font-size: 11px;
    color: var(--text-placeholder);
    margin-top: 2px;
}

/* Action Dropdown */
.action-dropdown {
    position: relative;
}

.btn-action-menu {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.btn-action-menu:hover {
    background: var(--bg-secondary);
    border-color: var(--text-faint);
}

.btn-action-menu i {
    font-size: 10px;
    color: var(--text-placeholder);
}

.action-menu-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99;
}

.action-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    min-width: 160px;
    padding: 6px;
    z-index: 100;
}

.action-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
}

.action-menu-item:hover {
    background: var(--bg-tertiary);
}

.action-menu-item i {
    width: 16px;
    color: var(--text-muted);
}

.action-menu-item.danger {
    color: var(--color-danger);
}

.action-menu-item.danger:hover {
    background: var(--color-danger-bg-subtle);
}

.action-menu-item.danger i {
    color: var(--color-danger);
}

.action-menu-item.success {
    color: var(--color-success);
}

.action-menu-item.success:hover {
    background: #ecfdf5;
}

.action-menu-item.success i {
    color: var(--color-success);
}

.action-menu-divider {
    height: 1px;
    background: var(--border-primary);
    margin: 6px 0;
}

/* Table Footer & Pagination */
.table-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-primary);
    border-radius: 0 0 16px 16px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}

.pagination-info strong {
    color: var(--text-primary);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 4px;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    border: 1px solid var(--border-primary);
    background: white;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.page-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--text-faint);
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

.page-ellipsis {
    padding: 0 8px;
    color: var(--text-placeholder);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border-primary);
    text-align: center;
}

.empty-state i {
    font-size: 48px;
    color: var(--text-faint);
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Loading */
.loading-container {
    display: flex;
    justify-content: center;
    padding: 60px 0;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.modal.show {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    width: 600px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    z-index: 1001;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.modal-close:hover {
    background: var(--border-primary);
    color: var(--text-secondary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.warning-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--color-danger);
    padding: 12px;
    background: var(--color-danger-bg-subtle);
    border-radius: 8px;
}

.warning-text i {
    font-size: 16px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-primary);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-secondary);
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input,
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.15s;
    background: white;
    color: var(--text-secondary);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
}

.form-checkbox label {
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--border-primary);
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.file-upload-area:hover {
    border-color: var(--color-primary);
    background: #f8fafc;
}

.file-upload-area i {
    font-size: 32px;
    color: var(--text-placeholder);
    margin-bottom: 12px;
}

.file-upload-area p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

.file-upload-area .file-types {
    font-size: 12px;
    color: var(--text-placeholder);
    margin-top: 4px;
}

.file-selected {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--color-success-bg-subtle);
    border: 1px solid var(--color-success-border);
    border-radius: 8px;
    margin-top: 12px;
}

.file-selected i {
    font-size: 20px;
    color: #16a34a;
}

.file-selected .file-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.file-selected .file-remove {
    background: none;
    border: none;
    color: var(--text-placeholder);
    cursor: pointer;
    padding: 4px;
}

.file-selected .file-remove:hover {
    color: var(--color-danger);
}

/* Current File Display */
.current-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    margin-bottom: 12px;
}

.current-file i {
    font-size: 20px;
    color: var(--color-primary);
}

.current-file .file-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* Alerts */
.alert-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--color-danger-bg-subtle);
    border: 1px solid var(--color-danger-border);
    border-radius: 8px;
    font-size: 13px;
    color: var(--color-danger);
    margin-top: 16px;
}

.alert-success {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--color-success-bg-subtle);
    border: 1px solid var(--color-success-border);
    border-radius: 8px;
    font-size: 13px;
    color: #16a34a;
    margin-top: 16px;
}

/* Buttons — see design-tokens.css for canonical button rules. Page-scoped variants only below. */

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-success:hover {
    background: var(--color-success);
}

.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Form Validation */
.required {
    color: var(--color-danger);
}

.validation-error {
    display: block;
    font-size: 12px;
    color: var(--color-danger);
    margin-top: 4px;
}

/* Quick Actions Panel */
.quick-actions {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: #1f2937;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.selected-count {
    font-size: 13px;
    font-weight: 500;
    color: white;
    padding-right: 16px;
    border-right: 1px solid var(--text-tertiary);
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-faint);
    cursor: pointer;
    transition: all 0.15s;
}

.quick-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.quick-action-btn i {
    font-size: 14px;
}

/* View Template Panel */
.view-panel {
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border-primary);
    margin-bottom: 24px;
}

.view-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-primary);
}

.view-panel-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.view-panel-body {
    padding: 24px;
}

.view-field {
    margin-bottom: 20px;
}

.view-field:last-child {
    margin-bottom: 0;
}

.view-field-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.view-field-value {
    font-size: 14px;
    color: var(--text-primary);
}

.view-panel-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-primary);
    background: var(--bg-secondary);
}

/* Responsive */
@media (max-width: 1400px) {
    .templates-page .table-header,
    .templates-page .template-row {
        grid-template-columns: 40px minmax(150px, 2fr) minmax(70px, 1fr) 80px minmax(90px, 120px) 80px 90px;
        gap: 6px;
        padding: 12px 12px;
    }
}

@media (max-width: 1200px) {
    /* Hide approver column on medium screens */
    .col-approver {
        display: none;
    }

    .templates-page .table-header,
    .templates-page .template-row {
        grid-template-columns: 36px minmax(140px, 2fr) minmax(70px, 1fr) 75px 75px 85px;
        gap: 6px;
        padding: 12px 10px;
    }
}

@media (max-width: 1024px) {
    .templates-page .table-header,
    .templates-page .template-row {
        grid-template-columns: 36px minmax(120px, 2fr) minmax(60px, 1fr) 70px 70px 80px;
        gap: 4px;
        padding: 10px 8px;
    }

    .template-name span {
        font-size: 13px;
    }

    .template-description {
        font-size: 11px;
    }

    .btn-action-menu {
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 900px) {
    /* Hide type column */
    .col-type {
        display: none;
    }

    .templates-page .table-header,
    .templates-page .template-row {
        grid-template-columns: 36px minmax(120px, 2fr) 70px 70px 80px;
        gap: 4px;
    }
}

@media (max-width: 768px) {
    .filters-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters-left {
        flex-wrap: wrap;
    }

    .status-tabs {
        flex-wrap: wrap;
    }

    .table-header {
        display: none;
    }

    .template-row {
        display: flex;
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .col-type,
    .col-approver {
        display: block;
    }

    .col-checkbox {
        position: absolute;
        top: 16px;
        left: 16px;
    }

    .template-row {
        position: relative;
        padding-left: 48px;
    }

    .col-actions {
        width: 100%;
    }

    .btn-action-menu {
        width: 100%;
        justify-content: center;
    }

    .action-menu {
        left: 0;
        right: 0;
    }

    .modal.show {
        width: 95vw;
    }

    .quick-actions {
        left: 16px;
        right: 16px;
        transform: none;
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* My Approvals Tab */
.status-tab.my-approvals {
    margin-left: auto;
    border-left: 1px solid var(--text-faint);
    padding-left: 20px;
}

.status-tab.my-approvals i {
    font-size: 14px;
}

.status-tab.my-approvals.active {
    background: linear-gradient(135deg, var(--color-primary-bg), #ede9fe);
    color: var(--color-indigo);
}

.status-tab.my-approvals.active .tab-count {
    background: var(--color-indigo);
    color: white;
}

.status-tab.my-approvals .tab-count.highlight {
    background: var(--color-danger);
    color: white;
    animation: pulse-badge-initial 0.6s ease-out 2, pulse-badge-subtle 2s ease-in-out 1.2s infinite;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7);
}

/* Large initial pulse - plays 2 times on page load */
@keyframes pulse-badge-initial {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.8);
    }
    50% {
        transform: scale(1.4);
        box-shadow: 0 0 0 12px rgba(220, 38, 38, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0);
    }
}

/* Subtle continuous pulse - plays after initial animation */
@keyframes pulse-badge-subtle {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 4px rgba(220, 38, 38, 0);
    }
}

/* ════════════════════════════════════════════════════════════════════════
   Workflow chip on the Templates table — clicking jumps to the Engage
   Approval Flows tab with the flow already open in edit mode.
   ════════════════════════════════════════════════════════════════════════ */
.col-workflow {
    overflow: hidden;
}

.workflow-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-tertiary, #f1f5f9);
    color: var(--text-primary, #1e293b);
    border: 1px solid var(--border-primary, #d4d4d8);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    max-width: 100%;
    transition: background 0.15s, border-color 0.15s;
}

.workflow-chip:hover {
    background: var(--bg-secondary, #e2e8f0);
    border-color: var(--color-primary, #4f46e5);
}

.workflow-chip .bi-diagram-3 {
    color: var(--color-primary, #4f46e5);
    font-size: 11px;
    flex-shrink: 0;
}

.workflow-chip-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ════════════════════════════════════════════════════════════════════════
   LetterApprovalFlowsPanel — sub-tabs, list cards, inline editors.
   Lives inside .templates-page so all selectors are scoped there.
   ════════════════════════════════════════════════════════════════════════ */
.approval-flows-panel {
    padding: 8px 0;
}

.approval-flows-panel .sub-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    border-bottom: 1px solid var(--border-primary, #d4d4d8);
    margin-bottom: 16px;
    padding-bottom: 0;
}

.approval-flows-panel .sub-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted, #64748b);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.approval-flows-panel .sub-tab:hover {
    color: var(--text-primary, #1e293b);
}

.approval-flows-panel .sub-tab.active {
    color: var(--color-primary, #4f46e5);
    border-bottom-color: var(--color-primary, #4f46e5);
}

.approval-flows-panel .sub-tab-count {
    display: inline-block;
    padding: 1px 7px;
    background: var(--bg-tertiary, #f1f5f9);
    color: var(--text-muted, #64748b);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.approval-flows-panel .sub-tab.active .sub-tab-count {
    background: var(--color-primary, #4f46e5);
    color: #fff;
}

.approval-flows-panel .sub-tabs-spacer { flex: 1; }

/* "Manage approver groups in Users → Approver Groups" pointer banner. Replaced
   the old Groups sub-tab when group CRUD moved to the Users page. */
.approval-flows-panel .approver-groups-hint {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary, #f1f5f9);
    border: 1px solid var(--border-primary, #d4d4d8);
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-muted, #64748b);
}

.approval-flows-panel .approver-groups-hint .bi {
    color: var(--color-primary, #4f46e5);
    font-size: 13px;
}

.approval-flows-panel .approver-groups-hint a {
    color: var(--color-primary, #4f46e5);
    text-decoration: none;
    font-weight: 500;
}

.approval-flows-panel .approver-groups-hint a:hover {
    text-decoration: underline;
}

/* Flow + group cards */
.flow-list, .group-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.flow-card, .group-card {
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-primary, #d4d4d8);
    border-radius: 10px;
    padding: 16px;
}

.flow-card-header, .group-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.flow-card-title, .group-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.flow-card-title h3, .group-card-title h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #1e293b);
}

.flow-card-actions, .group-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.flow-card-description, .group-card-description {
    margin: 0 0 10px;
    font-size: 13px;
    color: var(--text-muted, #64748b);
}

.flow-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted, #64748b);
    margin-bottom: 10px;
}

.flow-card-meta .bi { font-size: 11px; }
.flow-meta-sep { opacity: 0.4; }

.flow-card-steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.flow-step-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-tertiary, #f1f5f9);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-primary, #1e293b);
}

.flow-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--color-primary, #4f46e5);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 700;
}

.flow-step-arrow {
    color: var(--text-muted, #94a3b8);
    font-size: 12px;
}

.flow-step-arrow:last-child { display: none; }

.flow-step-end {
    color: var(--color-success, #16a34a);
    font-weight: 700;
    font-size: 14px;
}

.group-card-members {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.member-chip {
    display: inline-block;
    padding: 3px 10px;
    background: var(--bg-tertiary, #f1f5f9);
    border-radius: 999px;
    font-size: 12px;
    color: var(--text-primary, #1e293b);
}

/* Inline editors */
.flow-editor, .group-editor {
    background: var(--bg-primary, #fff);
    border: 1px solid var(--border-primary, #d4d4d8);
    border-radius: 12px;
    padding: 20px;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-primary, #d4d4d8);
}

.editor-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.editor-header-actions { display: flex; gap: 8px; }

.editor-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
    margin-bottom: 20px;
}

.form-group-full { grid-column: 1 / -1; }

.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-muted, #64748b);
}

.radio-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary, #1e293b);
}

.editor-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-primary, #d4d4d8);
}

.editor-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.editor-section-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #64748b);
}

.editor-section-actions { display: flex; gap: 6px; }

/* ─── Visio-style step canvas ────────────────────────────────────────────
   The "Steps" section renders as a horizontal row of numbered bubbles
   connected by short lines, with a dashed "+ Add Step" bubble at the end.
   Clicking any bubble selects it and surfaces its fields in the Properties
   panel below. Red dashed arcs (rendered into .flow-overlay by
   flowDesigner.js) visualize per-step rejection routes.
*/

.flow-canvas-section {
    /* Allow the canvas + properties panel to share vertical space. */
}

.flow-canvas-hint {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.flow-canvas-wrapper {
    background: var(--bg-secondary, #f9fafb);
    border: 1px solid var(--border-primary, #e5e7eb);
    border-radius: 10px;
    padding: 28px 20px 22px;
    overflow-x: auto;
    /* The SVG overlay paints arcs that can extend ABOVE the bubble row,
       so we need headroom inside the canvas. */
    padding-top: 64px;
}

.flow-canvas {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
    min-height: 96px;
    /* Shrink-to-fit so the canvas is exactly as wide as the bubble row, no more.
       Combined with auto side-margins this centers the row inside the wrapper
       when there's empty space on either side. When the row outgrows the
       wrapper, fit-content caps at the wrapper width and overflow-x:auto on
       .flow-canvas-wrapper kicks in — wide flows scroll horizontally as before. */
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.flow-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.flow-bubble {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--bg-primary, #ffffff);
    border: 2px solid var(--border-primary, #e5e7eb);
    color: var(--text-primary, #111827);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color .12s ease, border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}

.flow-bubble:hover {
    border-color: var(--color-primary, #2563eb);
    background: var(--color-primary-bg-subtle, #eff6ff);
}

.flow-bubble.is-selected {
    background: var(--color-primary, #2563eb);
    border-color: var(--color-primary-hover, #1d4ed8);
    color: #ffffff;
    box-shadow: 0 0 0 4px var(--color-primary-bg, #dbeafe);
}

.flow-bubble-num {
    font-size: 18px;
    font-weight: 700;
    font-family: var(--font-sans, -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif);
}

/* Kind chip in the bubble's top-right corner — tells you at a glance whether
   the step is Approval (primary) or Review (accent teal). */
.flow-bubble-kind {
    position: absolute;
    top: -8px;
    right: -10px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid var(--border-primary, #e5e7eb);
    background: var(--bg-primary, #ffffff);
    color: var(--text-muted, #6b7280);
    line-height: 1;
}

/* Kind chip text stays black for both Approval and Review — the chip's
   pill outline + position is enough visual differentiation; colored text
   was reading as purple/indigo to users. */
.flow-bubble-kind.approval { color: var(--text-primary, #111827); }
.flow-bubble-kind.review   { color: var(--text-primary, #111827); }
.flow-bubble-kind.signature { color: #d97706; } /* Amber-600 for the Send chip — distinct from blue Approval and black Review */
.flow-bubble-kind.external { color: #0d9488; } /* Teal-600 for the External Review chip */

.flow-bubble.is-selected .flow-bubble-kind {
    background: var(--bg-primary, #ffffff);
}

/* Bubble label sits BELOW the bubble (absolute, so it doesn't push the row
   apart). Shows the step name or assignee for quick scan. */
.flow-bubble-label {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted, #6b7280);
    white-space: nowrap;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.flow-bubble.is-selected .flow-bubble-label {
    color: var(--color-primary-hover, #1d4ed8);
    font-weight: 600;
}

/* Connector line between two adjacent bubbles. The little arrowhead is
   composed with a small border-right rotation for visual flow. */
.flow-connector {
    flex: 0 0 96px;
    height: 2px;
    background: var(--border-primary, #e5e7eb);
    margin: 0 6px;
    position: relative;
    z-index: 0;
}

.flow-connector::after {
    content: "";
    position: absolute;
    right: -1px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-top: 2px solid var(--border-primary, #e5e7eb);
    border-right: 2px solid var(--border-primary, #e5e7eb);
    transform: translateY(-50%) rotate(45deg);
}

.flow-connector-add {
    background: transparent;
    border-top: 2px dashed var(--border-primary, #e5e7eb);
    height: 0;
}
.flow-connector-add::after { display: none; }

/* Dashed "+ Add Step" bubble at the end of the row. */
.flow-bubble-add {
    border: 2px dashed var(--border-primary, #d1d5db);
    background: transparent;
    color: var(--text-muted, #6b7280);
}

.flow-bubble-add:hover {
    border-color: var(--color-primary, #2563eb);
    background: var(--color-primary-bg-subtle, #eff6ff);
    color: var(--color-primary, #2563eb);
}

.flow-bubble-add .bi { font-size: 20px; }

.flow-bubble-add-label {
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--text-muted, #6b7280);
    white-space: nowrap;
    pointer-events: none;
}

/* ─── Properties panel ───────────────────────────────────────────────────
   Drops in below the canvas when a bubble is selected. The two-column grid
   mirrors the rest of the form-group / form-label / form-input language
   used in the flow editor so it doesn't read as a separate widget. */
.flow-properties {
    margin-top: 28px;
    background: var(--color-primary-bg-subtle, #eff6ff);
    border: 1px solid var(--color-primary-bg, #dbeafe);
    border-radius: 10px;
    padding: 16px 18px;
}

.flow-properties-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-primary-bg, #dbeafe);
}

.flow-properties-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.flow-properties-pip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--color-primary, #2563eb);
    color: #ffffff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
}

.flow-properties-title h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #111827);
    text-transform: none;
    letter-spacing: 0;
}

.flow-properties-actions {
    display: flex;
    gap: 6px;
}

.flow-properties-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 20px;
}

.flow-properties-grid .form-label .bi {
    margin-right: 4px;
    color: var(--text-muted, #6b7280);
}

.step-reject-info {
    font-size: 12px;
    color: var(--text-muted, #6b7280);
}

.step-reject-info em {
    color: var(--text-muted, #9ca3af);
    font-style: italic;
}

.step-permissions-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    color: var(--text-primary, #111827);
}

.step-permissions-option input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--color-primary, #2563eb);
}

/* Step-kind toggle keeps its existing pill shape; Review uses the Engage
   accent teal so it's visually distinct from the primary blue Approval. */
.step-kind-toggle .kind.active {
    background: #0d9488;
}

.step-assignee-toggle {
    display: inline-flex;
    border: 1px solid var(--border-primary, #d4d4d8);
    border-radius: 6px;
    overflow: hidden;
}

.step-assignee-toggle .kind {
    padding: 5px 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted, #64748b);
}

.step-assignee-toggle .kind.active {
    background: var(--color-primary, #4f46e5);
    color: #fff;
}

.assignment-row {
    display: grid;
    grid-template-columns: 70px minmax(220px, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 6px 0;
}

.assignment-kind {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted, #64748b);
}

.hint-text {
    font-size: 12px;
    color: var(--text-muted, #64748b);
    margin: 4px 0;
}

.hint-text.muted { opacity: 0.75; font-style: italic; }

.member-picker {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border-primary, #d4d4d8);
    border-radius: 8px;
    padding: 6px;
}

.member-picker-row {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
}

.member-picker-row:hover { background: var(--bg-tertiary, #f1f5f9); }
.member-picker-name { font-size: 13px; color: var(--text-primary, #1e293b); }
.member-picker-email { font-size: 12px; color: var(--text-muted, #64748b); }

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-primary, #d4d4d8);
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-muted, #64748b);
    font-size: 12px;
    line-height: 1;
}

.btn-icon:hover:not(:disabled) {
    background: var(--bg-tertiary, #f1f5f9);
    color: var(--text-primary, #1e293b);
}

.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-icon.danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--color-danger, #ef4444);
    color: var(--color-danger, #ef4444);
}
