/**
 * Summernote Templates Admin UI - CSS Styles
 * 
 * Styles für das Admin-Interface des Template-Managers
 * @version 1.0.0
 * @author RISE CRM Plugin
 */

/* ===================================
   Admin Page Layout
   =================================== */

.templates-admin-container {
    padding: 20px 0;
}

.templates-admin-header {
    margin-bottom: 30px;
}

.templates-admin-header h1 {
    font-size: 28px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
}

.templates-admin-header p {
    color: #6c757d;
    font-size: 14px;
}


/* ===================================
   Statistics Cards
   =================================== */

.template-stats-row {
    margin-bottom: 30px;
}

.template-stat-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.template-stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.template-stat-card .stat-icon {
    font-size: 32px;
    margin-bottom: 10px;
    opacity: 0.7;
}

.template-stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.template-stat-card .stat-label {
    font-size: 13px;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stat card colors */
.template-stat-card.stat-primary .stat-icon {
    color: #557bbb;
}

.template-stat-card.stat-success .stat-icon {
    color: #28a745;
}

.template-stat-card.stat-warning .stat-icon {
    color: #ffc107;
}

.template-stat-card.stat-info .stat-icon {
    color: #17a2b8;
}


/* ===================================
   Toolbar / Action Bar
   =================================== */

.template-toolbar {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.template-toolbar-left,
.template-toolbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.template-toolbar .btn {
    font-size: 14px;
    padding: 8px 16px;
    border-radius: 6px;
}

.template-toolbar .btn i {
    margin-right: 6px;
}


/* ===================================
   Filter Section
   =================================== */

.template-filters {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
}

.template-filters .form-group {
    margin-bottom: 15px;
}

.template-filters .form-group:last-child {
    margin-bottom: 0;
}

.template-filters label {
    font-size: 13px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
}

.template-filters .form-control,
.template-filters .form-select {
    font-size: 14px;
    border-radius: 6px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}


/* ===================================
   Template Grid
   =================================== */

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.template-card-wrapper {
    position: relative;
}

.template-card {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

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

/* Card States */
.template-card.template-active {
    border-color: #28a745;
}

.template-card.template-inactive {
    opacity: 0.7;
}

.template-card.template-custom {
    border-left: 4px solid #ffc107;
}

/* Card Checkbox */
.template-card-checkbox {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
}

.template-card-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Card Preview Image */
.template-card-preview {
    position: relative;
    height: 180px;
    overflow: hidden;
    background: #f8f9fa;
}

.template-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.template-card:hover .template-card-preview img {
    transform: scale(1.05);
}

/* Card Overlay */
.template-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.template-card:hover .template-card-overlay {
    opacity: 1;
}

.template-card-overlay .btn {
    font-size: 12px;
    padding: 6px 12px;
}

/* Card Badges */
.template-card-badges {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    z-index: 5;
}

.template-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.template-badge.badge-active {
    color: #28a745;
}

.template-badge.badge-inactive {
    color: #6c757d;
}

.template-badge.badge-custom {
    color: #ffc107;
}

/* Card Body */
.template-card-body {
    padding: 15px;
    flex: 1;
}

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

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

/* Card Meta */
.template-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid #e9ecef;
    font-size: 12px;
    color: #6c757d;
}

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

.template-card-meta-item i {
    font-size: 14px;
}

/* Card Footer */
.template-card-footer {
    padding: 12px 15px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.template-card-footer .btn {
    flex: 1;
    font-size: 13px;
    padding: 6px 10px;
}


/* ===================================
   Empty State
   =================================== */

.template-empty-state {
    text-align: center;
    padding: 80px 20px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    margin: 40px 0;
}

.template-empty-state-icon {
    font-size: 64px;
    color: #dee2e6;
    margin-bottom: 20px;
}

.template-empty-state h3 {
    font-size: 22px;
    color: #495057;
    margin-bottom: 10px;
}

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

.template-empty-state .btn {
    margin-top: 10px;
}


/* ===================================
   Upload Modal
   =================================== */

.upload-template-modal .modal-dialog {
    max-width: 700px;
}

.upload-zone {
    border: 2px dashed #ced4da;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: #557bbb;
    background: #e7f1ff;
}

.upload-zone-icon {
    font-size: 48px;
    color: #6c757d;
    margin-bottom: 15px;
}

.upload-zone-text {
    font-size: 14px;
    color: #495057;
    margin-bottom: 10px;
}

.upload-zone-hint {
    font-size: 12px;
    color: #6c757d;
}

.upload-preview {
    margin-top: 20px;
    padding: 20px;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.upload-preview-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 4px;
}

.upload-preview-code {
    max-height: 300px;
    overflow-y: auto;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
}


/* ===================================
   Template Preview Modal
   =================================== */

.template-view-modal .modal-dialog {
    max-width: 1000px;
}

.template-view-modal .nav-tabs {
    border-bottom: 2px solid #e9ecef;
}

.template-view-modal .nav-tabs .nav-link {
    color: #6c757d;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 12px 24px;
    font-weight: 500;
    font-size: 14px;
}

.template-view-modal .nav-tabs .nav-link:hover {
    color: #557bbb;
    border-bottom-color: #c8d4e5;
}

.template-view-modal .nav-tabs .nav-link.active {
    color: #557bbb;
    background: transparent;
    border-bottom-color: #557bbb;
}

.template-view-modal .tab-content {
    padding: 20px 0;
    min-height: 400px;
}

.template-code-viewer {
    background: #282c34;
    color: #abb2bf;
    padding: 20px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
}

.template-variables-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.template-variables-list li {
    padding: 10px 15px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 8px;
    font-family: monospace;
    font-size: 13px;
}


/* ===================================
   Pagination
   =================================== */

.template-pagination {
    display: flex;
    justify-content: center;
    margin-top: 30px;
}

.template-pagination .pagination {
    gap: 5px;
}

.template-pagination .page-link {
    border-radius: 6px;
    padding: 8px 16px;
    color: #557bbb;
    border: 1px solid #e9ecef;
}

.template-pagination .page-link:hover {
    background: #e7f1ff;
    border-color: #557bbb;
}

.template-pagination .page-item.active .page-link {
    background: #557bbb;
    border-color: #557bbb;
}


/* ===================================
   Loading State
   =================================== */

.template-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.template-loading-spinner {
    text-align: center;
}

.template-loading-spinner .spinner-border {
    width: 3rem;
    height: 3rem;
    color: #557bbb;
}

.template-loading-spinner p {
    margin-top: 15px;
    color: #6c757d;
    font-size: 14px;
}


/* ===================================
   Responsive Design
   =================================== */

@media (max-width: 1200px) {
    .template-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }
}

@media (max-width: 992px) {
    .template-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
    
    .template-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .template-toolbar-left,
    .template-toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .template-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 12px;
    }
    
    .template-card-preview {
        height: 140px;
    }
    
    .templates-admin-header h1 {
        font-size: 24px;
    }
    
    .template-stat-card .stat-value {
        font-size: 24px;
    }
}

@media (max-width: 576px) {
    .template-grid {
        grid-template-columns: 1fr;
    }
    
    .template-card-preview {
        height: 200px;
    }
    
    .template-toolbar .btn {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .template-stat-row {
        margin-bottom: 15px;
    }
    
    .template-stat-card {
        margin-bottom: 15px;
    }
}


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

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

.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(85, 123, 187, 0.25);
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .template-card {
        border-width: 3px;
    }
    
    .template-badge {
        border: 2px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .template-card,
    .template-card-preview img,
    .template-card-overlay,
    .upload-zone {
        transition: none;
    }
}


/* ===================================
   Print Styles
   =================================== */

@media print {
    .template-toolbar,
    .template-filters,
    .template-card-overlay,
    .template-card-checkbox,
    .template-card-footer {
        display: none !important;
    }
    
    .template-grid {
        display: block;
    }
    
    .template-card {
        page-break-inside: avoid;
        margin-bottom: 20px;
    }
}
