/* ==========================================================================
   MENU TEMPLATES TAB STYLES - COMPLETELY REWRITTEN
   ========================================================================== */

/* Reset and Base Styles */
* {
    box-sizing: border-box;
}

/* Header Section */
.menu-templates-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(212, 165, 116, 0.2);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* Custom Message Banner */
.custom-message-banner {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.75rem 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 165, 116, 0.2);
    border-left: 4px solid #ffc107;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(212, 165, 116, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    animation: slideInDown 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

.custom-message-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, #ffc107, #ffb300);
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.custom-message-icon {
    font-size: 2rem;
    flex-shrink: 0;
    animation: pulse 2s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(255, 193, 7, 0.3));
}

.custom-message-text {
    flex: 1;
    font-size: 1rem;
    font-weight: 500;
    color: #2d3748;
    line-height: 1.8;
}

.custom-message-text strong {
    color: #1e293b;
    font-weight: 700;
}

.custom-message-text br {
    margin-bottom: 4px;
}

.custom-message-close {
    background: rgba(212, 165, 116, 0.1);
    border: 1px solid rgba(212, 165, 116, 0.2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.custom-message-close:hover {
    background: rgba(212, 165, 116, 0.2);
    border-color: #d4a574;
    transform: scale(1.1) rotate(90deg);
}

.custom-message-close i {
    color: #d4a574;
    font-size: 1rem;
}

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

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.menu-templates-title h2 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 600;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-templates-title p {
    margin: 0.5rem 0 0 0;
    color: #718096;
    font-size: 0.95rem;
    font-weight: 400;
}

.menu-templates-actions {
    display: flex;
    gap: 1rem;
}

.menu-templates-actions .btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 140px;
    justify-content: center;
}

.menu-templates-actions .btn i {
    font-size: 0.9em;
}

.menu-templates-actions .btn-primary {
    background: linear-gradient(135deg, #d4a574, #c49464);
    color: white;
    box-shadow: 0 4px 15px rgba(212, 165, 116, 0.3);
}

.menu-templates-actions .btn-primary:hover {
    background: linear-gradient(135deg, #e6b885, #d4a574);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.4);
}

.menu-templates-actions .btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: #4a5568;
    border: 1px solid rgba(212, 165, 116, 0.3);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.menu-templates-actions .btn-secondary:hover {
    background: rgba(255, 255, 255, 1);
    color: #d4a574;
    border-color: #d4a574;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Navigation Tabs */
.menu-templates-nav {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #dee2e6;
}

.menu-template-nav-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: #6c757d;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.menu-template-nav-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.menu-template-nav-btn.active {
    background: #d4a574;
    color: white;
    box-shadow: 0 2px 4px rgba(212, 165, 116, 0.3);
}

/* Section Visibility */
.menu-template-section {
    display: none;
}

.menu-template-section.active {
    display: block;
}

/* Templates Grid */
.menu-templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
    width: 100%;
}

/* Ensure better distribution on larger screens */
@media (min-width: 1200px) {
    .menu-templates-grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: none;
    }
}

@media (min-width: 900px) and (max-width: 1199px) {
    .menu-templates-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 600px) and (max-width: 899px) {
    .menu-templates-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   Пагинация под грида с картите
   Всичко тук е скоупнато в .menu-templates-pagination - базовите
   .pagination-* правила по-долу се ползват и от други табове.
   ========================================================================== */

/* Собствена бяла лента, за да не се губи върху бежовия фон на страницата */
.menu-templates-pagination {
    width: 100%;
    margin-top: 1.5rem;
    padding: 1.25rem 1.5rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 165, 116, 0.25);
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(212, 165, 116, 0.12), 0 2px 8px rgba(0, 0, 0, 0.05);
}

.menu-templates-pagination:empty {
    display: none;
}

.menu-templates-pagination .pagination-info {
    display: inline-block;
    margin: 0 0 14px;
    padding: 8px 18px;
    background: rgba(212, 165, 116, 0.18);
    border: 1px solid rgba(212, 165, 116, 0.45);
    color: #8a6240;
}

.menu-templates-pagination .pagination-controls {
    margin-top: 0;
    padding: 0;
    border-top: none;
}

.menu-templates-pagination .pagination-btn {
    background: #fff;
    border: 1px solid rgba(212, 165, 116, 0.45);
    color: #8a6240;
    /* без transform - редът бутони не бива да подскача при hover */
    transition: background-color 0.2s ease, border-color 0.2s ease,
                color 0.2s ease, box-shadow 0.2s ease;
}

.menu-templates-pagination .pagination-btn:hover:not(.active) {
    background: #f7e7d6;
    border-color: #c49464;
    color: #6f4c2c;
    box-shadow: 0 2px 8px rgba(196, 148, 100, 0.25);
    transform: none;
}

.menu-templates-pagination .pagination-btn:active:not(.active) {
    background: #efd9c2;
    box-shadow: inset 0 1px 3px rgba(122, 84, 50, 0.2);
}

.menu-templates-pagination .pagination-btn.active,
.menu-templates-pagination .pagination-btn.active:hover {
    background: linear-gradient(135deg, #c08c56, #a97240);
    border-color: #a97240;
    color: #fff;
    box-shadow: 0 2px 10px rgba(169, 114, 64, 0.35);
    cursor: default;
    transform: none;
}

.menu-templates-pagination .pagination-btn:focus-visible {
    outline: 2px solid #a97240;
    outline-offset: 2px;
}

.menu-templates-pagination .pagination-dots {
    color: #b08d6a;
}

@media (max-width: 768px) {
    .menu-templates-pagination {
        margin-top: 1.25rem;
        padding: 1rem;
    }
}

.menu-template-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(212, 165, 116, 0.2);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: 0 4px 16px rgba(212, 165, 116, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.menu-template-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 165, 116, 0.1), transparent);
    transition: left 0.6s ease;
}

.menu-template-card:hover::before {
    left: 100%;
}

.menu-template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 32px rgba(212, 165, 116, 0.2), 0 4px 16px rgba(0, 0, 0, 0.1);
    border-color: #d4a574;
    background: rgba(255, 255, 255, 0.95);
}

.template-card-header {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(212, 165, 116, 0.2);
    position: relative;
    z-index: 1;
}

.template-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 0.75rem 0;
    background: linear-gradient(135deg, #d4a574, #c49464);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.template-info {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.15rem 0.75rem;
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
}

/* ❗ Без `nowrap` всеки от двата елемента се пречупва МЕЖДУ числото и
   думата, когато картата стане по-тясна от ~242px (пет колони на тесен
   десктоп). А тъй като `space-between` ги дърпа в двата края, вторите им
   редове се оказват допрени и се чете „артикулакатегории". */
.template-info > span {
    white-space: nowrap;
}

.template-items-preview {
    margin-bottom: 1.75rem;
    position: relative;
    z-index: 1;
}

.template-items-preview h5 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: #1e293b;
    font-weight: 600;
}

.template-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.category-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 15px;
    font-size: 0.7rem;
    font-weight: 500;
    background: rgba(212, 165, 116, 0.1);
    color: #d4a574;
    border: 1px solid rgba(212, 165, 116, 0.3);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.category-badge.has-items {
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.2), rgba(196, 148, 100, 0.2));
    color: #c49464;
    border-color: rgba(212, 165, 116, 0.5);
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.15);
}

.category-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.2);
}

.template-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* Responsive design for template actions */
@media (max-width: 768px) {
    .template-actions {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }

    .template-actions .btn {
        width: 100%;
        max-width: 200px;
    }
}

/* Button icon styles */
.template-actions .btn i {
    font-size: 0.9em;
    margin-right: 0.3rem;
    display: inline-block;
    width: 1em;
    text-align: center;
}

.template-actions .btn:last-child i {
    margin-right: 0;
}

/* Large screen optimizations for button widths */
@media (min-width: 1060px) {
    .template-actions .btn:first-child,
    .template-actions .btn:nth-child(2),
    .template-actions .btn:nth-child(3) {
        min-width: 125px;
    }

    .template-actions .btn:last-child {
        min-width: 50px;
    }
}

.template-actions .btn {
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    border-radius: 8px;
    font-weight: 500;
    min-width: 100px;
    white-space: nowrap;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

/* Specific button styles for template actions */
/* Използвай бутон (златист) */
.template-actions .btn:first-child {
    background: linear-gradient(135deg, #d4a574, #c49464);
    color: white;
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.3);
}

.template-actions .btn:first-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.4);
    background: linear-gradient(135deg, #e6b885, #d4a574);
}

/* Редактирай бутон (пастелен оранжев/праскова) */
.template-actions .btn:nth-child(2) {
    background: linear-gradient(135deg, #fff7ed, #fed7aa);
    color: #c2410c;
    border: 1px solid rgba(194, 65, 12, 0.2);
    box-shadow: 0 2px 8px rgba(251, 146, 60, 0.15);
}

.template-actions .btn:nth-child(2):hover {
    background: linear-gradient(135deg, #fed7aa, #fdba74);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(251, 146, 60, 0.25);
    color: #9a3412;
}

/* Копирай бутон (пастелен тюркоаз/мента) - компактен като изтрий */
.template-actions .btn:nth-child(3) {
    background: linear-gradient(135deg, #f0fdfa, #ccfbf1);
    color: #0f766e;
    border: 1px solid rgba(15, 118, 110, 0.2);
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.15);
    min-width: 50px;
    padding: 0.6rem 0.75rem;
}

.template-actions .btn:nth-child(3):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(20, 184, 166, 0.25);
    background: linear-gradient(135deg, #ccfbf1, #99f6e4);
    color: #0d5c54;
}

.template-actions .btn:nth-child(3) i {
    margin-right: 0;
}

/* Изтрий бутон (червен) */
.template-actions .btn:last-child {
    background: linear-gradient(135deg, #fef2f2, #fecaca);
    color: #991b1b;
    border: 1px solid rgba(239, 68, 68, 0.2);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1);
}

.template-actions .btn:last-child:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
    background: linear-gradient(135deg, #fecaca, #fca5a5);
    color: #7f1d1d;
}

/* Create Template Form - COMPLETELY REWRITTEN */
.create-template-form {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: none;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.create-template-form h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #495057;
}

.form-group {
    margin-bottom: 1.5rem;
    width: 100%;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #495057;
    font-size: 1rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #d4a574;
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

/* Template name input - more visible border */
#template-name {
    border: 2px solid #94a3b8 !important;
    background-color: #f8f9fa;
}

#template-name:focus {
    border-color: #d4a574 !important;
    background-color: white;
}

/* Template Items Selector - COMPLETELY REWRITTEN */
.template-items-selector {
    margin-bottom: 2rem;
    width: 100%;
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

.template-items-selector h4 {
    margin: 0 0 1.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #495057;
    text-align: center;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #d4a574;
}

/* Categories Grid - COMPLETELY REWRITTEN */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    width: 100%;
}

/* Category Box - COMPLETELY REWRITTEN */
.category-box {
    background: #ffffff;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 1.5rem;
    height: 400px;
    overflow-y: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.category-box:hover {
    border-color: #d4a574;
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.15);
}

.category-box h5 {
    margin: 0 0 1rem 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #495057;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Items List - COMPLETELY REWRITTEN */
.items-list {
    display: block;
    width: 100%;
    min-height: 50px;
    flex: 1;
}

/* Item Checkbox - COMPLETELY REWRITTEN */
.item-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    background: #f8f9fa;
}

.item-checkbox:hover {
    background: #e9ecef;
    border-color: #d4a574;
    transform: translateX(2px);
}

.item-checkbox input[type="checkbox"] {
    margin: 0;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.item-checkbox label {
    margin: 0;
    cursor: pointer;
    font-size: 0.9rem;
    color: #495057;
    line-height: 1.4;
    font-weight: 500;
    flex: 1;
}

/* Form Actions - REWRITTEN */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding-top: 2rem;
    margin-top: 2rem;
    border-top: 2px solid #dee2e6;
}

.form-actions .btn {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.3s ease;
    min-width: 150px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #dee2e6;
}

.empty-state h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.25rem;
    color: #495057;
}

.empty-state p {
    margin: 0 0 1.5rem 0;
    font-size: 0.9rem;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #dee2e6;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #495057;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #495057;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding: 1.5rem;
    border-top: 1px solid #dee2e6;
}

.text-muted {
    color: #6c757d;
    font-size: 0.875rem;
}

/* Scrollbar Styling */
.category-box::-webkit-scrollbar {
    width: 8px;
}

.category-box::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.category-box::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.category-box::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .menu-templates-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .menu-templates-actions {
        justify-content: center;
    }

    .menu-templates-nav {
        flex-direction: column;
    }

    .categories-grid {
        grid-template-columns: 1fr;
    }

    .category-box {
        height: 300px;
    }

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

    .form-actions .btn {
        min-width: auto;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    /* Template cards responsive */
    .menu-templates-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .template-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .template-actions .btn {
        min-width: auto;
        width: 100%;
    }
}

/* Additional Enhancements */
.category-box:focus-within {
    border-color: #d4a574;
    box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

.item-checkbox input[type="checkbox"]:checked + label {
    color: #d4a574;
    font-weight: 600;
}

.item-checkbox:has(input:checked) {
    background: #faf8f5;
    border-color: #d4a574;
}

/* ==========================================================================
   NEW UI DESIGN - Category Tabs and Cards (Menu Generator Style)
   ========================================================================== */

/* Category Tabs */
.category-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 5px;
}



.category-tab {
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 10px 10px 0 0;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    position: relative;
    font-size: 0.95rem;
}

.category-tab:hover {
    background: rgba(212, 165, 116, 0.1);
    color: #d4a574;
}

.category-tab.active {
    background: linear-gradient(135deg, #d4a574, #c49464);
    color: white;
    box-shadow: 0 -2px 10px rgba(212, 165, 116, 0.3);
}

.category-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(135deg, #d4a574, #c49464);
}

/* Additional improvements for all screens */
.category-tab {
    flex-shrink: 0;
    min-width: fit-content;
}

/* Category Content */
.template-items-selector .category-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 10px;
    min-height: 400px !important;
    height: 400px !important;
    display: block !important;
}

.category-panel {
    display: none;
}

.category-panel.active {
    display: block;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.quick-btn {
    padding: 8px 16px;
    background: rgba(212, 165, 116, 0.1);
    border: 1px solid rgba(212, 165, 116, 0.3);
    border-radius: 25px;
    color: #d4a574;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.quick-btn:hover {
    background: rgba(212, 165, 116, 0.2);
    border-color: rgba(212, 165, 116, 0.5);
    transform: translateY(-1px);
}

.search-input {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(212, 165, 116, 0.3);
    border-radius: 25px;
    color: #333;
    font-size: 0.85rem;
    font-weight: 500;
    outline: none;
    transition: all 0.3s ease;
    min-width: 200px;
}

.search-input:focus {
    border-color: rgba(212, 165, 116, 0.6);
    box-shadow: 0 0 0 2px rgba(212, 165, 116, 0.1);
}

.search-input::placeholder {
    color: #999;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    padding-top: 10px;
    padding-left: 5px;
}

.checkbox-item {
    flex: 0 0 calc(25% - 15px);
    max-width: calc(25% - 15px);
    min-height: 120px;
    position: relative;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.06), 0 1px 3px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.checkbox-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 165, 116, 0.1), transparent);
    transition: left 0.6s;
}

.checkbox-item:hover::before {
    left: 100%;
}

.checkbox-item:hover {
    transform: translateY(-2px);
    border-color: #d4a574;
    box-shadow: 0 8px 24px rgba(212, 165, 116, 0.15), 0 3px 8px rgba(0,0,0,0.06);
    overflow: hidden;
}

.checkbox-item.selected {
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.1), rgba(196, 148, 100, 0.1));
    border-color: #d4a574;
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgba(212, 165, 116, 0.22), 0 3px 10px rgba(0,0,0,0.06);
}

.checkbox-item.selected::after {
    content: '✓';
    position: absolute;
    top: 10px;
    right: 15px;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #d4a574, #c49464);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    animation: checkmark 0.6s ease-out;
}

.checkbox-item input[type="checkbox"] {
    display: none;
}

.checkbox-item-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-item-title {
    font-weight: 600;
    color: #1e293b;
    font-size: 1rem;
    line-height: 1.3;
    margin-bottom: 4px;
}

.checkbox-item.selected .checkbox-item-title {
    color: #d4a574;
}

.checkbox-item-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: #64748b;
}

.checkbox-item-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.checkbox-item-meta span::before {
    content: '';
    width: 6px;
    height: 6px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.6;
}

.checkbox-item-meta span:nth-child(2) {
    color: #d4a574;
    font-weight: 600;
}

.checkbox-item-meta span:last-child {
    color: #999;
}

/* Checkmark animation */
@keyframes checkmark {
    0% {
        transform: scale(0) rotate(45deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(45deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(45deg);
        opacity: 1;
    }
}

/* Responsive Design for New UI */
@media (max-width: 1200px) {
    .checkbox-item {
        flex: 0 0 calc(33.333% - 14px);
        max-width: calc(33.333% - 14px);
    }
}

@media (max-width: 768px) {
    .checkbox-item {
        flex: 0 0 calc(50% - 10px);
        max-width: calc(50% - 10px);
        min-height: 29px;
    }

    .checkbox-group {
        gap: 10px;
    }

    .category-tab {
        padding: 6px 9px;
    }

    .search-input {
        min-width: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .checkbox-item {
        flex: 0 0 calc(50% - 5px);
        max-width: calc(50% - 5px);
    }
}

/* ==========================================================================
   PAGINATION STYLES
   ========================================================================== */

/* Pagination Info */
.pagination-info {
    text-align: center;
    margin-bottom: 15px;
    padding: 8px 16px;
    background: rgba(212, 165, 116, 0.1);
    border-radius: 20px;
    color: #d4a574;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(212, 165, 116, 0.2);
}

/* Pagination Controls */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
    padding: 15px 0;
    border-top: 1px solid rgba(212, 165, 116, 0.2);
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid rgba(212, 165, 116, 0.3);
    border-radius: 6px;
    color: #d4a574;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 40px;
    text-align: center;
}

.pagination-btn:hover:not(.active) {
    background: rgba(212, 165, 116, 0.1);
    border-color: rgba(212, 165, 116, 0.5);
    transform: translateY(-1px);
}

.pagination-btn.active {
    background: linear-gradient(135deg, #d4a574, #c49464);
    color: white;
    border-color: #d4a574;
    box-shadow: 0 2px 8px rgba(212, 165, 116, 0.3);
}

.pagination-btn.active:hover {
    background: linear-gradient(135deg, #d4a574, #c49464);
    color: white;
    border-color: #d4a574;
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.4);
    transform: translateY(-1px);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.pagination-btn:disabled:hover {
    background: white;
    border-color: rgba(212, 165, 116, 0.3);
    transform: none;
}

.pagination-dots {
    padding: 8px 4px;
    color: #999;
    font-weight: bold;
    user-select: none;
}

/* Responsive Pagination */
@media (max-width: 768px) {
    .pagination-controls {
        gap: 4px;
    }

    .pagination-btn {
        padding: 6px 10px;
        font-size: 0.85rem;
        min-width: 36px;
    }

    .pagination-info {
        font-size: 0.85rem;
        margin-bottom: 10px;
    }
}

@media (max-width: 480px) {
    .pagination-controls {
        flex-wrap: wrap;
        gap: 6px;
    }

    .pagination-btn {
        padding: 8px 12px;
        min-width: 44px;
    }
}

/* ==========================================================================
   ГОЛЕМИ ЕКРАНИ (≥600px)

   Картата беше разлята от отстояния (падинг 1.75rem, заглавие
   „Категории:" с 1rem под него, 0.75rem между чиповете), а четирите
   бутона бяха flex с `flex-wrap` и се чупеха на три реда в тясна колона
   („Използвай" сам, после „Редактирай" + копие, после кошчето).
   Сега са в един ред: двата с етикет се делят мястото, а двете икони
   са с фиксирана широчина.
   ========================================================================== */
@media (min-width: 600px) {
    .menu-templates-grid { gap: 1rem; }

    .menu-template-card { padding: 1.15rem; }

    .template-card-header {
        margin-bottom: 0.85rem;
        padding-bottom: 0.65rem;
    }

    .template-name {
        font-size: 1.1rem;
        margin-bottom: 0.45rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .template-info { font-size: 0.8rem; }

    .template-items-preview { margin-bottom: 0.9rem; }

    /* Заглавието „Категории:" заемаше цял ред и не казваше нищо,
       което чиповете под него да не казват сами. */
    .template-items-preview h5 { display: none; }

    .template-categories { gap: 0.35rem; }

    .category-badge {
        padding: 0.2rem 0.45rem;
        font-size: 0.68rem;
        border-radius: 12px;
    }

    /* Четирите действия на един ред, без пренасяне.
       Побеждава старото `@media (max-width: 768px)` правило в диапазона
       600-768px, което ги редеше един под друг на цяла широчина. */
    /* Копирането и триенето се качват В ГОРНИЯ ДЕСЕН ЪГЪЛ на картата.
       Така долният ред остава само за двата основни бутона и етикетите им
       се побират цели - в един ред от четири бутона „Редактирай" се режеше
       в карта от ~280px (4 колони на 1200px).
       Разрушителното действие също така слиза от до „Използвай". */
    /* Мястото за ъгловите бутони се резервира САМО за заглавието.
       На целия хедър то отнемаше 72px и от реда с броевете, който е ПОД
       бутоните и няма как да се сблъска с тях - затова се пренасяше на два реда. */
    .template-name { padding-right: 72px; }

    .template-actions {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 0.5rem;
        margin-top: 0;
        flex-wrap: nowrap;
    }

    .template-actions .btn:nth-child(3),
    .template-actions .btn:nth-child(4) {
        position: absolute;
        top: 1.05rem;
        width: 30px;
        height: 30px;
        padding: 0;
        border-radius: 8px;
        /* Над `.menu-template-card::before` - блясъкът при hover минава през
           цялата карта и иначе би хванал клика. */
        z-index: 3;
    }

    .template-actions .btn:nth-child(3) { right: calc(1.15rem + 34px); }
    .template-actions .btn:nth-child(4) { right: 1.15rem; }

    /* ❗ Селекторите са с `:nth-child()`, а не само `.btn`: старите правила
       задават `min-width: 125px` през `:first-child`/`:nth-child(2)` и с просто
       `.template-actions .btn` те побеждават по специфичност - бутоните
       излизаха извън колоните на грида и се припокриваха. */
    .template-actions .btn:nth-child(1),
    .template-actions .btn:nth-child(2),
    .template-actions .btn:nth-child(3),
    .template-actions .btn:nth-child(4) {
        width: auto;
        max-width: none;
        min-width: 0;
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
        border-radius: 9px;
        white-space: nowrap;
        overflow: hidden;
    }

    /* ИДВА СЛЕД общото `width: auto` по-горе - при еднаква специфичност
       последното правило бие, иначе ъгъловите бутони се свиват до иконата
       и остават без цветния си фон. */
    .template-actions .btn:nth-child(3),
    .template-actions .btn:nth-child(4) {
        width: 30px;
        height: 30px;
        padding: 0;
    }

    .template-actions .btn i { margin-right: 0.25rem; }
    .template-actions .btn:nth-child(3) i,
    .template-actions .btn:nth-child(4) i { margin-right: 0; }

    /* `text-overflow` не важи за inline елемент - без `display:block` етикетът
       се режеше на сухо („Използв", „Редактир"). */
    .tpl-btn-label {
        display: block;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ❗ Старо правило `@media (max-width: 768px) { .menu-templates-grid { 1fr } }`
   стои СЛЕД `(min-width: 600px) and (max-width: 899px)` и го отменяше:
   между 600 и 768px картите излизаха по една на ред върху цялата широчина.
   Това го връща на две колони, без да пипа по-големите прагове. */
@media (min-width: 600px) and (max-width: 899px) {
    .menu-templates-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* На много широки екрани се губеше място - четири колони от 400px+.
   ЗАБЕЛЕЖКА: `getTemplatesGridColumns()` чете реалните колони от грида,
   така че пагинацията се нагажда сама; фолбекът в JS също знае за този праг. */
@media (min-width: 1600px) {
    .menu-templates-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ==========================================================================
   МАЛКИ ЕКРАНИ (≤599px, с отделна настройка за ≤360px)

   Преди това на телефон картите бяха по 1 на ред, всяка с пълния списък
   категории и четири бутона един под друг - една карта заемаше почти цял
   екран и в дисплея се събираха две. Тук: 2 на ред, без списъка с категории
   (броят им е в реда отгоре), „Използвай" на цял ред и останалите три като
   икони.
   ========================================================================== */
@media (max-width: 599px) {

    /* --- Хедър: бутоните се събират, вместо да излизат извън екрана ------ */
    .menu-templates-header {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 14px;
        gap: 0.75rem;
    }

    .menu-templates-title h2 { font-size: 1.15rem; }
    .menu-templates-title p { font-size: 0.8rem; margin-top: 0.25rem; }

    .menu-templates-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.4rem;
    }

    .menu-templates-actions .btn {
        min-width: 0;            /* беше 140px - оттам идваше отрязаният бутон */
        padding: 0.55rem 0.35rem;
        font-size: 0.72rem;
        gap: 0.25rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* --- Гридът с картите ------------------------------------------------ */
    .menu-templates-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.6rem;
        margin-top: 0.75rem;
    }

    .menu-template-card {
        padding: 0.7rem;
        border-radius: 12px;
    }

    /* Няма hover на тъч - анимацията само мести картите под пръста. */
    .menu-template-card:hover {
        transform: none;
        box-shadow: 0 4px 16px rgba(212, 165, 116, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
    }

    .template-card-header {
        margin-bottom: 0.6rem;
        padding-bottom: 0.5rem;
    }

    .template-name {
        font-size: 0.95rem;
        margin-bottom: 0.35rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .template-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.1rem;
        font-size: 0.72rem;
    }

    /* Осем чипа в карта от ~160px стават шест реда и не казват нищо повече
       от броя, който вече се вижда отгоре. */
    .template-items-preview { display: none; }

    /* --- Бутоните: „Използвай" на цял ред, останалите като икони -------- */
    .template-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.3rem;
        margin-top: 0;
    }

    .template-actions .btn {
        width: auto;
        max-width: none;
        min-width: 0;
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
        border-radius: 8px;
    }

    .template-actions .btn:first-child {
        grid-column: 1 / -1;
    }

    .template-actions .btn:not(:first-child) .tpl-btn-label { display: none; }
    .template-actions .btn:not(:first-child) i { margin-right: 0; }

    /* --- Пагинация ------------------------------------------------------- */
    .menu-templates-pagination { padding: 0.75rem; }
    .menu-templates-pagination .pagination-info { font-size: 0.75rem; }
    .menu-templates-pagination .pagination-btn {
        min-width: 34px;
        padding: 6px 8px;
        font-size: 0.8rem;
    }
}

/* Най-тесните телефони (≤360px): хедър бутоните минават на 2 реда, за да
   остане четим текст, вместо три отрязани етикета. */
@media (max-width: 360px) {
    .menu-templates-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .menu-templates-actions .btn:last-child {
        grid-column: 1 / -1;
    }

    .menu-templates-grid { gap: 0.45rem; }
    .menu-template-card { padding: 0.55rem; }
    .template-name { font-size: 0.88rem; }
    .template-actions .btn { font-size: 0.7rem; padding: 0.45rem 0.2rem; }
}

/* ==========================================================================
   05.10.2026 - „близо до сегашния" (docs/mockups/gen-week-tpl.html)
   Същата решетка, същото съдържание и същите действия; ново облекло в езика
   на Обекти/менюто на профила. Тялото на таба е карта с лентата (tab-card.css),
   затова заглавието вече не е отделна бяла кутия.
   ❗ Колоните на .menu-templates-grid НЕ се пипат - menu-templates.js смята
   страниците по тях (getTemplatesGridColumns).
   ========================================================================== */
#menu-templates-content { color: #3f3328; }

#menu-templates-content .menu-templates-header {
    flex-wrap: wrap; gap: 14px; margin-bottom: 18px; padding: 0;
    border: 0; border-radius: 0; background: none; box-shadow: none; backdrop-filter: none;
}
#menu-templates-content .menu-templates-title h2 { font-size: 1.4rem; font-weight: 800; color: #2b231d; }
#menu-templates-content .menu-templates-title p { margin-top: 4px; font-size: .92rem; color: #8a7866; }
#menu-templates-content .menu-templates-actions { flex-wrap: wrap; gap: 8px; }
#menu-templates-content .menu-templates-actions .btn {
    min-width: 0; padding: 10px 16px; border: 1px solid #e6d4bf; border-radius: 12px;
    background: #fff; color: #3f3328; box-shadow: none; font-weight: 700; font-size: .9rem;
}
#menu-templates-content .menu-templates-actions .btn::before { display: none; }
#menu-templates-content .menu-templates-actions .btn i { color: #a8743f; }
#menu-templates-content .menu-templates-actions .btn:hover { background: #fbf4ec; color: #3f3328; border-color: #e6d4bf; transform: none; box-shadow: none; }
#menu-templates-content .menu-templates-actions .btn-primary { border-color: #3a2f26; background: #3a2f26; color: #fff; }
#menu-templates-content .menu-templates-actions .btn-primary i { color: #f1d3a6; }
#menu-templates-content .menu-templates-actions .btn-primary:hover { background: #2b231d; color: #fff; border-color: #2b231d; }

/* ---- картата */
.menu-template-card.tpl-card {
    display: flex; flex-direction: column; min-width: 0; padding: 18px;
    border: 1px solid #efe4d8; border-radius: 16px; background: #fff;
    container-type: inline-size;
    box-shadow: none; backdrop-filter: none; overflow: visible;
    transition: border-color .12s, box-shadow .12s;
}
.menu-template-card.tpl-card::before { display: none; }
.menu-template-card.tpl-card:hover { border-color: #e0c49e; box-shadow: 0 10px 26px rgba(60, 40, 25, .08); transform: none; }

.tpl-name { margin: 0; font-size: 1.12rem; font-weight: 800; line-height: 1.3; color: #2b231d; overflow-wrap: anywhere; }
.tpl-info { margin-top: 4px; font-size: .82rem; color: #8a7866; }
.tpl-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tpl-cat {
    display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 4px 10px;
    border: 1px solid #efe4d8; border-radius: 999px; background: #fbf4ec;
    font-size: .76rem; font-weight: 700; color: #5a4a3a;
}
.tpl-cat b { color: #a8743f; }

/* ---- действията: „Използвай" на цял ред, отдолу „Редактирай" + две иконки */
.tpl-actions { display: flex; flex-direction: column; gap: 6px; margin-top: auto; padding-top: 16px; }
.tpl-actions-row { display: flex; gap: 6px; min-width: 0; }
.tpl-btn {
    min-width: 0; min-height: 0; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 12px; border: 1px solid #e6d4bf; border-radius: 11px; background: #fff; color: #3f3328;
    font: inherit; font-size: .86rem; font-weight: 700; white-space: nowrap; cursor: pointer;
    transition: background .12s, border-color .12s;
}
.tpl-btn i { color: #a8743f; }
.tpl-btn:hover { background: #fbf4ec; }
.tpl-btn:focus-visible { outline: 3px solid #e0b98a; outline-offset: 2px; }
.tpl-btn--use { width: 100%; border-color: #3a2f26; background: #3a2f26; color: #fff; }
.tpl-btn--use i { color: #f1d3a6; }
.tpl-btn--use:hover { background: #2b231d; }
.tpl-btn--edit { flex: 1 1 auto; padding-left: 8px; padding-right: 8px; overflow: hidden; text-overflow: ellipsis; }
.tpl-btn--icon { flex: none; width: 34px; padding: 0; }
.tpl-btn--danger i { color: #b3261e; }
.tpl-btn--danger:hover { border-color: #f5cdc2; background: #fdecea; }

/* ---- страниците отдолу */
#menu-templates-content .menu-templates-pagination { border-top-color: #f1e8de; }
#menu-templates-content .menu-templates-pagination .pagination-info { color: #8a7866; }
#menu-templates-content .menu-templates-pagination .pagination-btn { border-color: #efe4d8; background: #fff; color: #5a4a3a; box-shadow: none; }
#menu-templates-content .menu-templates-pagination .pagination-btn.active { border-color: #3a2f26; background: #3a2f26; color: #fff; }

/* Карта, по-тясна от реда „Редактирай" + две иконки (5 колони на 1600px,
   2 колони на телефон): етикетът се скрива и остават три иконки. Мери се
   самата карта (вътрешната ширина, без отстъпите), а не екранът - ширината ѝ
   зависи от броя колони. Редът иска ~193px вътре. */
@container (max-width: 192px) {
    .tpl-btn--edit { flex: 1 1 0; padding: 0; }
    .tpl-edit-label { display: none; }
    .tpl-btn--icon { flex: 1 1 0; width: auto; }
}

@media (pointer: coarse) {
    .tpl-btn { min-height: 44px; }
    .tpl-btn--icon { width: 44px; }
}

/* Под 600px картите са по 2 на ред (~160px) - „Редактирай" остава само икона,
   категориите се крият (броят им е в реда отгоре), както и преди. */
@media (max-width: 600px) {
    .menu-template-card.tpl-card { padding: 12px; }
    .tpl-name { font-size: .98rem; }
    .tpl-cats { display: none; }
    .tpl-actions { padding-top: 12px; }
    .tpl-btn--use { padding: 9px 6px; }
    .tpl-btn--edit { flex: 1 1 0; padding: 0; }
    .tpl-edit-label { display: none; }
    .tpl-btn--icon { flex: 1 1 0; width: auto; }
}

/* ==========================================================================
   05.10.2026 - формата „Създаване / редактиране на шаблон" в новия изглед
   Същият език като генератора (menu-generator-v2.css): чипове за категориите,
   търсачката първа, ястията като редове с отметка, „Запази" в залепена лента.
   Всичко е под #menu-templates-content .create-template-form - формата се
   рисува в #menu-templates-manage (showCreateFormContent).
   ========================================================================== */
#menu-templates-content .create-template-form {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 20px; align-items: start;
    padding: 24px; border: 1px solid #efe4d8; border-radius: 18px; background: #fff; box-shadow: none; color: #3f3328;
}
#menu-templates-content .create-template-form > * { grid-column: 1 / -1; }
/* Името и датата - един до друг */
#menu-templates-content .create-template-form > .form-group { grid-column: auto; margin-bottom: 18px; }
#menu-templates-content .create-template-form h3 { margin: 0 0 16px; font-size: 1.25rem; font-weight: 800; color: #2b231d; }

#menu-templates-content .create-template-form .form-group label,
.tpl-date-label {
    display: block; margin-bottom: 8px; font-size: .74rem; font-weight: 800; letter-spacing: .06em;
    text-transform: uppercase; color: #8a7866;
}
.tpl-optional { margin-left: 4px; font-weight: 600; letter-spacing: 0; text-transform: none; color: #b3a08c; }
#menu-templates-content #template-name {
    min-height: 0; padding: 11px 14px; border: 1px solid #efe4d8 !important; border-radius: 12px;
    background: #fff; color: #2b231d; font-size: 1rem; font-weight: 700; box-shadow: none;
}
#menu-templates-content #template-name:focus { border-color: #d4a574 !important; box-shadow: 0 0 0 3px rgba(212, 165, 116, .25); outline: none; }

/* ---- датата */
.tpl-date-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-date-chip, .tpl-date-input {
    min-height: 0; display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px;
    border: 1px solid #efe4d8; border-radius: 12px; background: #fff; color: #5a4a3a;
    font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; transition: background .12s, border-color .12s;
}
.tpl-date-chip:hover, .tpl-date-input:hover { background: #fbf4ec; }
.tpl-date-chip.on, .tpl-date-input.on { border-color: #3a2f26; background: #3a2f26; color: #fff; }
.tpl-date-input i { color: #a8743f; }
.tpl-date-input.on i { color: #f1d3a6; }
#menu-templates-content .tpl-date-input input {
    width: auto; min-height: 0; margin: 0; padding: 0; border: 0; background: none; color: inherit;
    font: inherit; font-weight: 700; box-shadow: none; color-scheme: light;
}
.tpl-date-input.on input { color-scheme: dark; }
.tpl-date-chip:focus-visible, .tpl-date-input:focus-within { outline: 3px solid #e0b98a; outline-offset: 2px; }
.tpl-date-hint { margin: 8px 0 0; font-size: .82rem; color: #8a7866; }
.tpl-date-hint::first-letter { text-transform: uppercase; }

/* датата в картата на шаблона */
.tpl-date {
    display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin-top: 8px; padding: 3px 9px;
    border-radius: 999px; background: #3a2f26; color: #f1d3a6; font-size: .74rem; font-weight: 700;
}

/* ---- избор на артикули */
#menu-templates-content .create-template-form .template-items-selector { min-height: 0; margin: 4px 0 0; }
#menu-templates-content .create-template-form .template-items-selector h4 {
    display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 14px 0 0; border: 0; border-top: 1px solid #f1e8de;
    text-align: left; font-size: 1rem; font-weight: 800; color: #2b231d;
}
#menu-templates-content #selected-items-counter {
    margin-left: 0 !important; padding: 3px 10px !important; border-radius: 999px !important;
    background: #3a2f26 !important; color: #f1d3a6 !important; font-size: .78rem !important;
}

/* Пренасят се на нов ред; ако и 2 реда не стигат - два реда с плъзгане
   (utils.fitChipRows() слага chip-rows-scroll), в естествения ред. */
#menu-templates-content .create-template-form .category-tabs {
    display: flex; flex-wrap: wrap; overflow-x: visible; gap: 6px; margin: 0 0 12px; padding: 0 0 6px; border: 0;
}
#menu-templates-content .create-template-form .category-tabs.chip-rows-scroll { display: block; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin; }
#menu-templates-content .create-template-form .category-tabs .chip-rows-inner { display: flex; flex-wrap: wrap; gap: 6px; }
#menu-templates-content .create-template-form .category-tab {
    flex: none; min-height: 0; padding: 7px 14px; border: 1px solid #efe4d8; border-radius: 999px;
    background: #fff; color: #5a4a3a; box-shadow: none; font-size: .86rem; font-weight: 600;
}
#menu-templates-content .create-template-form .category-tab::after { display: none; }
#menu-templates-content .create-template-form .category-tab:hover { background: #fbf4ec; color: #3f3328; }
#menu-templates-content .create-template-form .category-tab.active { border-color: #3a2f26; background: #3a2f26; color: #fff; }

#menu-templates-content .create-template-form .category-content { min-height: 0; padding: 0; border: 0; background: none; box-shadow: none; }
#menu-templates-content .create-template-form .quick-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
#menu-templates-content .create-template-form .quick-actions .search-input {
    order: -1; flex: 1 1 260px; min-width: 0; min-height: 0; padding: 10px 12px; border: 1px solid #efe4d8; border-radius: 12px;
    background: #fff; color: #3f3328; box-shadow: none; font-size: .92rem;
}
#menu-templates-content .create-template-form .quick-actions .search-input:focus { outline: none; border-color: #d4a574; box-shadow: 0 0 0 3px rgba(212, 165, 116, .25); }
#menu-templates-content .create-template-form .quick-btn {
    min-height: 0; padding: 8px 12px; border: 1px solid #e6d4bf; border-radius: 10px; background: #fff; color: #5a4a3a;
    box-shadow: none; font-size: .84rem; font-weight: 700; transform: none;
}
#menu-templates-content .create-template-form .quick-btn:hover { background: #fbf4ec; transform: none; box-shadow: none; }
#menu-templates-content .create-template-form .pagination-info {
    margin: 0 0 6px; padding: 0; border: 0; border-radius: 0; background: none; text-align: left;
    font-size: .8rem; font-weight: 600; color: #8a7866;
}

/* ястията: редове с отметка */
#menu-templates-content .create-template-form .checkbox-group {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px 14px; margin: 0 0 8px; padding: 0;
}
#menu-templates-content .create-template-form .checkbox-item {
    flex: none; max-width: none; min-height: 0; flex-direction: row; align-items: center; justify-content: flex-start;
    padding: 9px 10px 9px 40px; border: 0; border-radius: 11px; background: none; box-shadow: none; overflow: visible; transform: none;
}
/* ❗ display: block - articles.css изключва `.checkbox-item::before` за цялото табло */
#menu-templates-content .create-template-form .checkbox-item::before {
    content: ''; display: block; position: absolute; top: 50%; left: 10px; width: 20px; height: 20px; transform: translateY(-50%);
    border: 2px solid #d9c6ae; border-radius: 6px; background: none; transition: none; box-sizing: border-box; pointer-events: none;
}
#menu-templates-content .create-template-form .checkbox-item:hover { background: #fbf4ec; transform: none; box-shadow: none; }
#menu-templates-content .create-template-form .checkbox-item.selected { background: #fbf4ec; border: 0; transform: none; box-shadow: none; }
#menu-templates-content .create-template-form .checkbox-item.selected::before { border-color: #3a2f26; background: #3a2f26; }
#menu-templates-content .create-template-form .checkbox-item.selected::after {
    content: '✓'; position: absolute; top: 50%; left: 10px; right: auto; width: 20px; height: 20px; transform: translateY(-50%);
    display: flex; align-items: center; justify-content: center; border-radius: 6px;
    background: none; color: #f1d3a6; font-size: 12px; font-weight: 700; animation: none; pointer-events: none;
}
#menu-templates-content .create-template-form .checkbox-item-content {
    display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; min-width: 0; text-align: left;
}
#menu-templates-content .create-template-form .checkbox-item-title {
    flex: 1; min-width: 0; margin: 0; font-size: .92rem; font-weight: 600; line-height: 1.35; color: #3f3328;
}
#menu-templates-content .create-template-form .checkbox-item-meta { flex: none; flex-wrap: nowrap; gap: 8px; margin: 0; }
#menu-templates-content .create-template-form .checkbox-item-meta span { padding: 0; background: none; font-size: .78rem; color: #8a7866; }
#menu-templates-content .create-template-form .checkbox-item-meta span::before { display: none; }
#menu-templates-content .create-template-form .checkbox-item-meta .price-primary { font-size: .9rem; font-weight: 700; color: #5a4a3a; }

#menu-templates-content .create-template-form .pagination-controls { margin-top: 8px; padding: 10px 0 0; border-top: 1px solid #f1e8de; }
#menu-templates-content .create-template-form .pagination-btn {
    min-height: 0; padding: 6px 12px; border: 1px solid #efe4d8; border-radius: 9px; background: #fff; color: #5a4a3a; box-shadow: none;
}
#menu-templates-content .create-template-form .pagination-btn.active { border-color: #3a2f26; background: #3a2f26; color: #fff; }

/* ---- „Запази / Отказ" - залепени за долния ръб, докато се отмята */
#menu-templates-content .create-template-form .form-actions {
    position: sticky; bottom: 0; z-index: 5; justify-content: flex-end; gap: 8px;
    margin: 12px -24px -24px; padding: 14px 24px; border-top: 1px solid #efe4d8; border-radius: 0 0 18px 18px; background: #fff;
}
#menu-templates-content .create-template-form .form-actions .btn {
    min-width: 0; min-height: 0; padding: 11px 18px; border: 1px solid #e6d4bf; border-radius: 12px;
    background: #fff; color: #3f3328; box-shadow: none; font-size: .92rem; font-weight: 700;
}
#menu-templates-content .create-template-form .form-actions .btn::before { display: none; }
#menu-templates-content .create-template-form .form-actions .btn:hover { background: #fbf4ec; transform: none; box-shadow: none; }
#menu-templates-content .create-template-form .form-actions .btn-primary { order: 2; border-color: #3a2f26; background: #3a2f26; color: #fff; }
#menu-templates-content .create-template-form .form-actions .btn-primary i { color: #f1d3a6; }
#menu-templates-content .create-template-form .form-actions .btn-primary:hover { background: #2b231d; }

@media (max-width: 1100px) {
    #menu-templates-content .create-template-form .checkbox-group { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    #menu-templates-content .create-template-form { grid-template-columns: minmax(0, 1fr); padding: 16px; }
    #menu-templates-content .create-template-form .form-actions { margin: 12px -16px -16px; padding: 12px 16px; }
}
/* Под 1024px долу има навигация - лентата застава над нея */
@media (max-width: 1023px) {
    #menu-templates-content .create-template-form .form-actions { bottom: calc(76px + env(safe-area-inset-bottom)); }
}
@media (max-width: 600px) {
    #menu-templates-content .create-template-form .checkbox-group { grid-template-columns: minmax(0, 1fr); }
    #menu-templates-content .create-template-form .form-actions .btn { flex: 1 1 0; justify-content: center; }
}
@media (pointer: coarse) {
    .tpl-date-chip, .tpl-date-input { min-height: 44px; }
}
