/* =========================================
   TEMPLATE MANAGER
   ========================================= */

/* Modal Overlay */
#template-manager-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    font-family: 'Roboto', sans-serif;
}
#template-manager-overlay.active { display: flex; }

/* Main Window */
#template-manager-window {
    width: 90%;
    max-width: 1200px;
    height: 85%;
    background: #111;
    color: #fff;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
}

/* Header */
.tm-header {
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
    background: #161616;
}
.tm-title-group h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}
.tm-count {
    background: #4CAF50;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    vertical-align: middle;
}
.tm-controls { display: flex; gap: 15px; align-items: center; }

/* Buttons */
.btn-tm-icon {
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s;
    padding: 5px;
}
.btn-tm-icon:hover { color: #fff; }

/* Content Area */
.tm-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Main Grid */
.tm-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    background: #000;
}

/* Section Headers */
.tm-section-group { margin-bottom: 30px; }
.tm-section-header {
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tm-section-header span {
    color: #4CAF50;
    font-weight: normal;
    font-size: 14px;
}

/* Grid */
.tm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
}

/* Template Card */
.tm-card {
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #333;
}
.tm-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    border-color: #555;
}

/* Built-in card distinction */
.tm-card-builtin {
    border-top: 3px solid #4CAF50;
}

.tm-card-preview {
    height: 140px;
    width: 100%;
    background: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.tm-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a1a 0%, #2a2a2a 100%);
}
.tm-card-placeholder i {
    font-size: 48px;
    color: #444;
}

.tm-card-info { padding: 12px; }
.tm-card-title {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tm-card-meta {
    font-size: 11px;
    color: #888;
}

/* Built-in badge */
.tm-badge-builtin {
    display: inline-block;
    background: #4CAF50;
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    margin-left: 6px;
    vertical-align: middle;
}

/* Hover Actions */
.tm-card-actions {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 140px;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 5;
}
.tm-card:hover .tm-card-actions { opacity: 1; }
.btn-tm-action {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}
.btn-tm-action:hover { background: #388E3C; }

/* Delete button on user cards */
.tm-card-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.tm-card:hover .tm-card-delete { opacity: 1; }
.tm-card-delete:hover { background: #c82333; }
.tm-card-delete i { font-size: 18px; }

/* Search Bar */
.tm-search-bar {
    background: #222;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 5px 10px;
    display: flex;
    align-items: center;
    width: 300px;
}
.tm-search-bar input {
    background: transparent;
    border: none;
    color: #fff;
    width: 100%;
    margin: 0;
    padding: 5px;
    font-size: 14px;
    outline: none;
}
.tm-search-bar i { color: #666; }

/* Context Menu */
#tm-context-menu {
    position: fixed;
    background: #222;
    border: 1px solid #444;
    border-radius: 4px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    z-index: 100000;
    display: none;
    min-width: 150px;
}
.tm-context-item {
    padding: 10px 15px;
    color: #eee;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tm-context-item:hover { background: #4CAF50; color: white; }
.tm-context-item i { font-size: 16px; }
.tm-context-separator { border-top: 1px solid #444; margin: 2px 0; }

/* Slide preview container inside cards */
.tm-slide-preview {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.tm-slide-preview-element {
    position: absolute;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

/* Empty state */
.tm-empty {
    text-align: center;
    color: #555;
    margin-top: 30px;
}
.tm-empty i {
    font-size: 48px;
    opacity: 0.5;
    display: block;
    margin-bottom: 10px;
}
