/**
 * Summernote Templates Plugin - CSS Styles
 * 
 * Styles für das Template-Plugin im Summernote Editor
 * @version 1.0.5
 * @author RISE CRM Plugin
 */

/* ===================================
   Template Button in Toolbar
   =================================== */

.note-btn.btn-template {
    position: relative;
}

.note-btn.btn-template .note-icon-magic {
    margin-right: 4px;
}


/* ===================================
   Template Selection Modal
   =================================== */

[id^="summernote-template-modal"] .modal-dialog {
    max-width: 900px;
}

[id^="summernote-template-modal"] .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* Template Controls */
.template-controls {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    padding: 15px 0;
    border-bottom: 1px solid #e9ecef;
}

.template-search {
    border-radius: 0.25rem;
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
}

.template-category-filter {
    border-radius: 0.25rem;
    border: 1px solid #ced4da;
    padding: 0.5rem 0.75rem;
}

/* Template List */
.template-list {
    padding: 20px 0;
}

.template-list.is-hidden {
    display: none;
}

.template-empty-state {
    display: none;
    margin-top: 16px;
    padding: 24px;
    text-align: center;
}

.template-empty-state.is-visible {
    display: block;
}

.template-empty-state .template-empty-state-title {
    margin-bottom: 8px;
}

.template-empty-state .template-empty-state-text {
    margin-bottom: 0;
}

.template-list .row {
    margin-left: -10px;
    margin-right: -10px;
}

.template-list .col-md-6,
.template-list .col-lg-4 {
    padding-left: 10px;
    padding-right: 10px;
}

/* Template Item Card */
.template-item.card {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    cursor: pointer;
}

.template-item.card:hover {
    border-color: #557bbb;
    box-shadow: 0 4px 12px rgba(85, 123, 187, 0.15);
    transform: translateY(-2px);
}

.template-item.card .card-img-top {
    height: 140px;
    object-fit: cover;
    background: #f8f9fa;
}

.template-item.card .card-body {
    padding: 12px;
}

.template-item.card .card-title {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.template-item.card .card-text {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Loading State */
.template-loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.template-loading .spinner-border {
    width: 3rem;
    height: 3rem;
    margin-bottom: 15px;
}

/* Empty State */
.template-empty {
    text-align: center;
    padding: 60px 20px;
    color: #6c757d;
}

.template-empty i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.3;
}

.template-empty h5 {
    color: #495057;
    margin-bottom: 10px;
}

.template-empty p {
    font-size: 14px;
    color: #6c757d;
}


/* ===================================
   Template Preview (in Editor)
   =================================== */

.template-preview-wrapper {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 20px;
    min-height: 200px;
    max-height: 500px;
    overflow-y: auto;
}

.template-preview-wrapper img {
    max-width: 100%;
    height: auto;
}

.template-preview-wrapper table {
    width: 100%;
    border-collapse: collapse;
}


/* ===================================
   Variables in Templates
   =================================== */

.template-variable {
    display: inline-block;
    background: #fff3cd;
    border: 1px dashed #ffc107;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #856404;
}

.template-placeholder {
    display: inline-block;
    background: #d1ecf1;
    border: 1px dashed #17a2b8;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    color: #0c5460;
}


/* ===================================
   Responsive Styles
   =================================== */

@media (max-width: 768px) {
    [id^="summernote-template-modal"] .modal-dialog {
        max-width: 95%;
        margin: 10px auto;
    }

    .template-controls .row > div {
        margin-bottom: 10px;
    }

    .template-list .col-md-6,
    .template-list .col-lg-4 {
        -webkit-box-flex: 0;
        -ms-flex: 0 0 100%;
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (max-width: 576px) {
    [id^="summernote-template-modal"] .modal-body {
        padding: 10px;
    }

    .template-controls {
        padding: 10px 0;
    }

    .template-item.card .card-img-top {
        height: 120px;
    }
}


/* ===================================
   Animation Effects
   =================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.template-item.card {
    animation: fadeIn 0.3s ease-in-out;
}

.template-item.card:nth-child(1) { animation-delay: 0.05s; }
.template-item.card:nth-child(2) { animation-delay: 0.10s; }
.template-item.card:nth-child(3) { animation-delay: 0.15s; }
.template-item.card:nth-child(4) { animation-delay: 0.20s; }
.template-item.card:nth-child(5) { animation-delay: 0.25s; }
.template-item.card:nth-child(6) { animation-delay: 0.30s; }


/* ===================================
   Category Badge
   =================================== */

.template-category-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #557bbb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 5;
}


/* ===================================
   Search Highlight
   =================================== */

.template-search-highlight {
    background-color: #fff3cd;
    padding: 1px 3px;
    border-radius: 2px;
}


/* ===================================
   Template Type Icons
   =================================== */

.template-type-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    margin-right: 5px;
    vertical-align: middle;
}

.template-type-icon.type-block::before {
    content: "□";
    font-size: 16px;
    color: #557bbb;
}

.template-type-icon.type-page::before {
    content: "📄";
    font-size: 14px;
}


/* ===================================
   Modal Tabs Styling
   =================================== */

[id^="summernote-template-modal"] .nav-tabs {
    border-bottom: 2px solid #e9ecef;
}

[id^="summernote-template-modal"] .nav-tabs .nav-link {
    color: #6c757d;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 10px 20px;
    font-weight: 500;
}

[id^="summernote-template-modal"] .nav-tabs .nav-link:hover {
    color: #557bbb;
    border-bottom-color: #c8d4e5;
}

[id^="summernote-template-modal"] .nav-tabs .nav-link.active {
    color: #557bbb;
    background: transparent;
    border-bottom-color: #557bbb;
}


/* ===================================
   Dark Mode Support (Optional)
   =================================== */

@media (prefers-color-scheme: dark) {
    .template-controls {
        background: #2c3e50;
        border-bottom-color: #34495e;
    }

    .template-item.card {
        background: #34495e;
        border-color: #4a5f7f;
    }

    .template-item.card .card-title {
        color: #ecf0f1;
    }

    .template-item.card .card-text {
        color: #95a5a6;
    }

    .template-preview-wrapper {
        background: #2c3e50;
        border-color: #34495e;
    }
}


/* ===================================
   Accessibility
   =================================== */

.template-item.card:focus {
    outline: 2px solid #557bbb;
    outline-offset: 2px;
}

.template-search:focus,
.template-category-filter:focus {
    border-color: #557bbb;
    box-shadow: 0 0 0 0.2rem rgba(85, 123, 187, 0.25);
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
