/* ==========================================================================
   TEMPLATES TAB - Professional Admin/Manager Interface
   ========================================================================== */

/* Main Templates Container */
.templates-admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    background: #f8f9fa;
    min-height: calc(100vh - 200px);
}

.templates-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding: 0;
}

/* Simple Header */
.simple-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding: 0 5px;
}

.simple-header h2 {
    margin: 0;
    font-size: 1.8em;
    font-weight: 600;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Control Panel */
.templates-controls {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
}

.controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Search and Filter */
.search-filter-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-input {
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    width: 250px;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-select {
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
}

/* Action Buttons */
.admin-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.admin-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.admin-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.admin-btn-secondary {
    background: #6c757d;
    color: white;
}

.admin-btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.admin-btn-success {
    background: #28a745;
    color: white;
}

.admin-btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
}

.admin-btn-danger {
    background: #dc3545;
    color: white;
}

.admin-btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
}

/* Templates Section */
.templates-section {
    margin-bottom: 3rem;
}

.templates-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* Template Card */
.template-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.template-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.template-card.template-loaded {
    border-color: #28a745;
    background: linear-gradient(135deg, white 0%, rgba(40, 167, 69, 0.02) 100%);
}

.template-card.template-not-loaded {
    border-color: #ffc107;
    background: linear-gradient(135deg, white 0%, rgba(255, 193, 7, 0.02) 100%);
}

/* Template Header */
.template-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.template-icon {
    font-size: 2.5em;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.template-info h3 {
    margin: 0 0 5px 0;
    font-size: 1.3em;
    font-weight: 600;
    color: #2c3e50;
}

.template-info p {
    margin: 0;
    color: #6c757d;
    font-size: 0.9em;
    line-height: 1.4;
}

/* Template Status */
.template-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-active {
    background: #d4edda;
    color: #155724;
}

.status-inactive {
    background: #f8d7da;
    color: #721c24;
}

.status-assigned {
    background: #d1ecf1;
    color: #0c5460;
}

/* Assignment Info */
.assignment-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.assignment-info h4 {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    font-weight: 600;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.assignment-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.assignment-item:last-child {
    border-bottom: none;
}

.assignment-name {
    font-weight: 500;
    color: #2c3e50;
}

.assignment-type {
    font-size: 0.8em;
    color: #6c757d;
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 12px;
}

.template-content {
    margin-bottom: 1.5rem;
}

.template-name {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
}

.template-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

.template-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.template-button-preview {
    background: var(--glass-bg-hover);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Template Actions */
.template-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.template-actions .admin-btn {
    flex: 1;
    min-width: 120px;
    justify-content: center;
    font-size: 0.85em;
    padding: 10px 15px;
}

/* Statistics Panel */
.templates-stats {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
}

.statistics-section {
    margin-bottom: 3rem;
}

.statistics-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.stat-icon {
    font-size: 2.5em;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    color: white;
}

.stat-content {
    flex: 1;
}

.stat-content h3 {
    margin: 0 0 5px 0;
    font-size: 2em;
    font-weight: 700;
    color: #667eea;
}

.stat-content p {
    margin: 0;
    font-size: 0.9em;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.stat-number {
    font-size: 2.5em;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 5px;
}

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

/* Filters Section */
.filters-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
}

.filters-header {
    margin-bottom: 20px;
}

.filters-header h3 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
    color: #2c3e50;
}

.filters-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.search-control {
    flex: 1;
    min-width: 250px;
}

.filter-control {
    display: flex;
    align-items: center;
}

/* No Templates State */
.no-templates {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.no-templates-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-templates h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
}

.no-templates p {
    margin: 0;
    font-size: 0.875rem;
}

/* Preview Section */
.preview-section {
    margin-bottom: 3rem;
}

.preview-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.preview-container {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-info span:first-child {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.preview-info span:last-child {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.preview-content {
    padding: 1.5rem;
}

.preview-wrapper {
    position: relative;
}

.preview-scale-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: center;
}

.preview-scale-controls .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 8px;
}

.preview-frame {
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    background: white;
    overflow: auto;
    max-height: 600px;
    transition: transform 0.3s ease;
}

/* Settings Section */
.settings-section {
    margin-bottom: 3rem;
}

.settings-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.setting-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: all 0.3s ease;
}

.setting-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.setting-icon {
    font-size: 2rem;
    opacity: 0.8;
    flex-shrink: 0;
}

.setting-content {
    flex: 1;
}

.setting-content h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-content p {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.setting-content .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: 8px;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.notification-success {
    border-left: 4px solid var(--success-color);
}

.notification-error {
    border-left: 4px solid var(--error-color);
}

.notification-info {
    border-left: 4px solid var(--primary-color);
}

.notification-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.notification-close:hover {
    background: var(--glass-bg-hover);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Users Management Section */
.users-management-section {
    margin-bottom: 3rem;
}

.users-management-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.section-description {
    color: #6c757d;
    font-size: 1rem;
    margin-bottom: 1.5rem;
    font-style: italic;
}

/* Organization Sections */
.organization-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid #e9ecef;
}

.organization-title {
    color: #495057;
    font-size: 1.2em;
    font-weight: 600;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 10px;
}

.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
}

.user-template-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

.user-template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* User info moved to main.css - this was conflicting with header user info */

/* User avatar styles moved to main.css */

.user-details {
    flex: 1;
}

.user-name {
    margin: 0 0 0.25rem 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-email {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.user-role {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-administrator {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.role-manager {
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.role-user {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.template-assignment {
    border-top: 1px solid var(--glass-border);
    padding-top: 1rem;
}

.current-template {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--glass-bg-hover);
    border-radius: 8px;
}

.template-icon {
    font-size: 1.2rem;
}

.template-name {
    font-weight: 500;
    color: var(--text-primary);
}

.template-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.template-selector {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: var(--glass-bg);
    color: var(--text-primary);
    font-size: 0.875rem;
}

.template-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* No Users State */
.no-users {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.no-users-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.no-users h4 {
    margin: 0 0 0.5rem 0;
    color: var(--text-secondary);
}

.no-users p {
    margin: 0;
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .templates-container {
        padding: 1rem;
    }

    .simple-header {
        flex-direction: column;
        align-items: center;
        gap: 15px;
        text-align: center;
    }

    .simple-header h2 {
        font-size: 1.5em;
        justify-content: center;
    }

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

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

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

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

    .template-actions .btn {
        flex: none;
    }

    .preview-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .preview-scale-controls {
        flex-wrap: wrap;
    }

    .user-template-card {
        padding: 1rem;
    }

    /* User info styles moved to main.css */

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

    /* Statistics responsive */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    .stat-card {
        padding: 15px;
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 2em;
    }

    .stat-content h3 {
        font-size: 1.5em;
    }

    /* Filters responsive */
    .filters-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .search-control {
        min-width: auto;
    }

    .filter-control {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
