/* ========================================
   MY TEMPLATES PAGE
   ======================================== */

.page-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}

.page-title-row .page-title {
    margin-bottom: var(--space-1);
}

.page-title-row .page-subtitle {
    margin-bottom: 0;
}

.btn-with-icon {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    white-space: nowrap;
}

.btn-with-icon i {
    width: 16px;
    height: 16px;
}

.template-count-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 10px;
    background: var(--background-secondary);
    color: var(--text-muted);
    border-radius: var(--radius-full);
    margin-left: var(--space-2);
}

.badge-beta {
    display: inline-flex;
    align-items: center;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    padding: 2px 8px;
    background: var(--brand-primary);
    color: var(--background-primary);
    border-radius: var(--radius-full);
    margin-left: var(--space-2);
    vertical-align: middle;
    position: relative;
    top: -2px;
}

/* Template list items */
.template-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.template-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--background-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    transition: all var(--transition-base);
}

.template-list-item:hover {
    border-color: var(--border-medium);
    box-shadow: var(--shadow-sm);
}

.template-list-info {
    flex: 1;
    min-width: 0;
}

.template-list-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9375rem;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.template-list-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: var(--space-1);
}

.template-list-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    white-space: nowrap;
}

.badge-shared {
    background: rgba(var(--purple-500-rgb), 0.1);
    color: var(--purple-500);
}

.badge-colleague {
    background: rgba(var(--info-500-rgb), 0.1);
    color: var(--info-500);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-medium);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: var(--background-primary);
    border-radius: 50%;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--brand-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* Icon buttons */
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
    text-decoration: none;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
}

.btn-icon-sm i {
    width: 16px;
    height: 16px;
}

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

.btn-icon-active {
    color: var(--purple-500);
    background: rgba(var(--purple-500-rgb), 0.08);
}

.btn-icon-active:hover {
    background: rgba(var(--purple-500-rgb), 0.15);
    color: var(--purple-600);
}

.btn-icon-danger:hover {
    background: rgba(var(--error-500-rgb), 0.08);
    color: var(--error);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-8) var(--space-4);
    text-align: center;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-secondary);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.empty-state-icon i {
    width: 24px;
    height: 24px;
}

.empty-state-text {
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.info-text {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
}

.info-text p {
    margin-bottom: var(--space-3);
}

.info-text p:last-child {
    margin-bottom: 0;
}


/* ========================================
   EDIT TEMPLATE PAGE
   ======================================== */

.template-edit-form {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.card-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: var(--space-5);
    line-height: 1.5;
}

/* Category add row */
.category-add-row {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.category-add-input {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9375rem;
    transition: border-color var(--transition-base);
    background: var(--background-primary);
}

.category-add-input:focus {
    outline: none;
    border-color: var(--brand-primary);
}

.category-add-input.input-error {
    border-color: var(--error);
    animation: shake 0.3s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* Category list (sortable) */
.category-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-height: 48px;
}

.category-item {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    background: var(--background-primary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-md);
    transition: all 0.15s ease;
    cursor: default;
    overflow: hidden;
}

.category-item:hover {
    border-color: var(--border-medium);
}

.category-item--dragging {
    opacity: 0.4;
    border-color: var(--brand-primary);
}

.category-item--drag-over {
    border-color: var(--brand-primary);
    background: rgba(var(--brand-primary-rgb), 0.06);
    transform: translateY(-2px);
}

.category-item-header {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
}

.category-item-body {
    padding: 0 var(--space-4) var(--space-3);
    padding-left: calc(var(--space-4) + 16px + var(--space-3) + 24px + var(--space-3));
}

.category-instructions-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.category-item-instructions {
    width: 100%;
    min-height: 130px;
    padding: var(--space-2) var(--space-3);
    border: 1.5px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background-secondary);
    resize: vertical;
    transition: border-color var(--transition-base), background var(--transition-base);
}

.category-item-instructions::placeholder {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.8125rem;
}

.category-item-instructions:focus {
    outline: none;
    border-color: var(--brand-primary);
    background: var(--background-primary);
}

.category-item-handle {
    cursor: grab;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding: var(--space-1);
    flex-shrink: 0;
}

.category-item-handle:active {
    cursor: grabbing;
}

.category-item-number {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}

.category-item-label {
    flex: 1;
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.category-item-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.category-item-remove:hover {
    background: rgba(var(--error-500-rgb), 0.08);
    color: var(--error);
}

.category-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-6);
    color: var(--text-muted);
    font-size: 0.875rem;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-md);
}

.categories-hint {
    margin-top: var(--space-3);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.categories-hint-sep {
    margin: 0 var(--space-1);
}

.categories-hint-tip {
    color: var(--text-muted);
    font-style: italic;
}

/* Radio pills for output settings */
.radio-pills {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.radio-pill {
    cursor: pointer;
}

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

.radio-pill-label {
    display: inline-block;
    padding: var(--space-2) var(--space-4);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--background-primary);
    border: 2px solid var(--border-light);
    border-radius: var(--radius-full);
    transition: all var(--transition-base);
}

.radio-pill:hover .radio-pill-label {
    border-color: var(--brand-primary);
    color: var(--brand-primary-dark);
}

.radio-pill input[type="radio"]:checked + .radio-pill-label {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--on-brand-primary);
    font-weight: 600;
}

/* Sticky form actions */
.form-actions-sticky {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-5) 0;
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, var(--background-secondary) 60%, transparent);
    padding-top: var(--space-8);
    z-index: 10;
}

.form-actions-sticky .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

/* Small button variant */
.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: 0.8125rem;
}

.btn-sm i {
    width: 14px;
    height: 14px;
}

@media (max-width: 768px) {
    .page-title-row {
        flex-direction: column;
        align-items: stretch;
    }

    .page-title-row .btn {
        width: 100%;
        justify-content: center;
    }

    .template-list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .template-list-actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: var(--space-3);
        border-top: 1px solid var(--border-light);
    }

    .category-add-row {
        flex-direction: column;
    }

    .radio-pills {
        gap: var(--space-2);
    }

    .form-actions-sticky {
        flex-direction: column-reverse;
    }

    .form-actions-sticky .btn {
        width: 100%;
        justify-content: center;
    }
}
