/* ============================================
   TEMPLATES DE RANKING - ROUTRELL ANALYTICS
   ============================================ */

#routrell-templates-ranking {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ============================================
   HEADER
   ============================================ */

#routrell-templates-ranking .templates-header {
    margin-bottom: 24px;
}

#routrell-templates-ranking .templates-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text, #1f2937);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

#routrell-templates-ranking .templates-title i {
    color: #3b82f6;
}

#routrell-templates-ranking .templates-subtitle {
    color: var(--text-secondary, #6b7280);
    margin: 0;
    font-size: 0.95rem;
}

/* ============================================
   BANNER TEMPLATE ATIVO
   ============================================ */

#routrell-templates-ranking .active-template-banner {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 12px;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

#routrell-templates-ranking .active-template-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#routrell-templates-ranking .active-template-icon i {
    font-size: 1.5rem;
    color: white;
}

#routrell-templates-ranking .active-template-info {
    flex: 1;
}

#routrell-templates-ranking .active-template-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.8);
    display: block;
    margin-bottom: 4px;
}

#routrell-templates-ranking .active-template-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    margin: 0 0 4px 0;
}

#routrell-templates-ranking .active-template-description {
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    font-size: 0.9rem;
}

/* ============================================
   FORMULÁRIO INLINE
   ============================================ */

#routrell-templates-ranking .template-form-container {
    background: var(--surface, #ffffff);
    border: 2px solid #3b82f6;
    border-radius: 12px;
    margin-bottom: 24px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.15);
}

#routrell-templates-ranking .template-form {
    padding: 0;
}

#routrell-templates-ranking .template-form-header {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#routrell-templates-ranking .template-form-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

#routrell-templates-ranking .btn-close-form {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#routrell-templates-ranking .btn-close-form:hover {
    background: rgba(255, 255, 255, 0.3);
}

#routrell-templates-ranking .template-form-body {
    padding: 24px;
}

#routrell-templates-ranking .form-section {
    margin-bottom: 24px;
}

#routrell-templates-ranking .form-section:last-child {
    margin-bottom: 0;
}

#routrell-templates-ranking .form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text, #1f2937);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

#routrell-templates-ranking .form-section-title i {
    color: #3b82f6;
}

#routrell-templates-ranking .form-section-description {
    color: var(--text-secondary, #6b7280);
    font-size: 0.875rem;
    margin: 0 0 16px 0;
}

#routrell-templates-ranking .form-group {
    margin-bottom: 16px;
}

#routrell-templates-ranking .form-group label {
    display: block;
    font-weight: 500;
    color: var(--text, #374151);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

#routrell-templates-ranking .form-input,
#routrell-templates-ranking .form-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text, #1f2937);
    background: var(--surface, #fff);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

#routrell-templates-ranking .form-input:focus,
#routrell-templates-ranking .form-textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#routrell-templates-ranking .form-textarea {
    resize: vertical;
    min-height: 60px;
}

/* ============================================
   CONFIGURAÇÃO DE PESOS
   ============================================ */

#routrell-templates-ranking .weights-config {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#routrell-templates-ranking .weight-item {
    background: var(--surface-secondary, #f9fafb);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    padding: 14px 16px;
}

#routrell-templates-ranking .weight-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

#routrell-templates-ranking .weight-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#routrell-templates-ranking .weight-item-icon.icon-create {
    background: #dcfce7;
    color: #16a34a;
}

#routrell-templates-ranking .weight-item-icon.icon-move {
    background: #dbeafe;
    color: #2563eb;
}

#routrell-templates-ranking .weight-item-icon.icon-update {
    background: #ffedd5;
    color: #ea580c;
}

#routrell-templates-ranking .weight-item-icon.icon-comment {
    background: #f3e8ff;
    color: #9333ea;
}

#routrell-templates-ranking .weight-item-icon.icon-complete {
    background: #cffafe;
    color: #0891b2;
}

#routrell-templates-ranking .weight-item-name {
    flex: 1;
    font-weight: 500;
    color: var(--text, #374151);
}

#routrell-templates-ranking .weight-item-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: #3b82f6;
    min-width: 50px;
    text-align: right;
}

#routrell-templates-ranking .weight-slider {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--border, #e5e7eb);
    border-radius: 4px;
    outline: none;
    cursor: pointer;
}

#routrell-templates-ranking .weight-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
    transition: transform 0.15s;
}

#routrell-templates-ranking .weight-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

#routrell-templates-ranking .weight-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #3b82f6;
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

/* ============================================
   TOTAL DOS PESOS
   ============================================ */

#routrell-templates-ranking .weights-total-container {
    margin-top: 20px;
    padding: 16px;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
}

#routrell-templates-ranking .weights-total-bar {
    height: 10px;
    background: var(--border, #e5e7eb);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 12px;
}

#routrell-templates-ranking .weights-total-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 5px;
    transition: width 0.3s, background-color 0.3s;
}

#routrell-templates-ranking .weights-total-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#routrell-templates-ranking .weights-total-label {
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
}

#routrell-templates-ranking .weights-total-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text, #1f2937);
}

#routrell-templates-ranking .weights-total-status {
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

#routrell-templates-ranking .weights-total-status.valid {
    color: #10b981;
}

#routrell-templates-ranking .weights-total-status.invalid {
    color: #ef4444;
}

/* ============================================
   FOOTER DO FORMULÁRIO
   ============================================ */

#routrell-templates-ranking .template-form-footer {
    padding: 16px 24px;
    background: var(--surface-secondary, #f9fafb);
    border-top: 1px solid var(--border, #e5e7eb);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

#routrell-templates-ranking .btn-secondary {
    padding: 10px 20px;
    background: var(--surface, #fff);
    border: 1px solid var(--border, #d1d5db);
    border-radius: 8px;
    color: var(--text, #374151);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

#routrell-templates-ranking .btn-secondary:hover {
    background: var(--surface-secondary, #f3f4f6);
}

#routrell-templates-ranking .btn-primary {
    padding: 10px 20px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: opacity 0.2s, transform 0.2s;
}

#routrell-templates-ranking .btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

#routrell-templates-ranking .btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   CONFIRMAÇÃO DE EXCLUSÃO INLINE
   ============================================ */

#routrell-templates-ranking .delete-confirmation {
    background: #fef2f2;
    border: 2px solid #fecaca;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

#routrell-templates-ranking .delete-confirmation-content {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

#routrell-templates-ranking .delete-confirmation-content > i {
    font-size: 1.5rem;
    color: #dc2626;
}

#routrell-templates-ranking .delete-confirmation-content > p {
    flex: 1;
    margin: 0;
    color: #991b1b;
    min-width: 200px;
}

#routrell-templates-ranking .delete-confirmation-actions {
    display: flex;
    gap: 12px;
}

#routrell-templates-ranking .btn-danger {
    padding: 10px 20px;
    background: #dc2626;
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

#routrell-templates-ranking .btn-danger:hover {
    background: #b91c1c;
}

/* ============================================
   BARRA DE AÇÕES
   ============================================ */

#routrell-templates-ranking .templates-actions-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

#routrell-templates-ranking .templates-count {
    color: var(--text-secondary, #6b7280);
    font-size: 0.95rem;
}

#routrell-templates-ranking .templates-count span {
    font-weight: 700;
    color: var(--text, #1f2937);
}

#routrell-templates-ranking .btn-new-template {
    padding: 12px 24px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

#routrell-templates-ranking .btn-new-template:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* ============================================
   GRID DE TEMPLATES
   ============================================ */

#routrell-templates-ranking .templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

#routrell-templates-ranking .templates-loading,
#routrell-templates-ranking .templates-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #6b7280);
}

#routrell-templates-ranking .templates-loading i,
#routrell-templates-ranking .templates-empty i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ============================================
   CARD DE TEMPLATE
   ============================================ */

#routrell-templates-ranking .template-card {
    background: var(--surface, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.2s, box-shadow 0.2s;
}

#routrell-templates-ranking .template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

#routrell-templates-ranking .template-card.is-active {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

#routrell-templates-ranking .template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

#routrell-templates-ranking .template-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text, #1f2937);
    margin: 0;
    flex: 1;
}

#routrell-templates-ranking .template-card-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

#routrell-templates-ranking .badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

#routrell-templates-ranking .badge-active {
    background: #dcfce7;
    color: #16a34a;
}

#routrell-templates-ranking .badge-default {
    background: #dbeafe;
    color: #2563eb;
}

#routrell-templates-ranking .badge-custom {
    background: #f3e8ff;
    color: #9333ea;
}

#routrell-templates-ranking .template-card-description {
    color: var(--text-secondary, #6b7280);
    font-size: 0.9rem;
    margin: 0 0 16px 0;
    line-height: 1.5;
}

/* ============================================
   PREVIEW DOS PESOS NO CARD
   ============================================ */

#routrell-templates-ranking .template-weights-preview {
    background: var(--surface-secondary, #f9fafb);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
}

#routrell-templates-ranking .weight-preview-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

#routrell-templates-ranking .weight-preview-item:not(:last-child) {
    border-bottom: 1px solid var(--border, #e5e7eb);
}

#routrell-templates-ranking .weight-preview-name {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary, #6b7280);
    font-size: 0.85rem;
}

#routrell-templates-ranking .weight-preview-name i {
    width: 16px;
    text-align: center;
}

#routrell-templates-ranking .weight-preview-value {
    font-weight: 600;
    color: #3b82f6;
    font-size: 0.9rem;
}

/* ============================================
   AÇÕES DO CARD
   ============================================ */

#routrell-templates-ranking .template-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#routrell-templates-ranking .btn-action {
    padding: 8px 14px;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 6px;
    background: var(--surface, #fff);
    color: var(--text, #374151);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

#routrell-templates-ranking .btn-action:hover:not(:disabled) {
    background: var(--surface-secondary, #f3f4f6);
    border-color: #9ca3af;
}

#routrell-templates-ranking .btn-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#routrell-templates-ranking .btn-activate:not(:disabled):hover {
    background: #dcfce7;
    border-color: #16a34a;
    color: #16a34a;
}

#routrell-templates-ranking .btn-duplicate:hover {
    background: #dbeafe;
    border-color: #2563eb;
    color: #2563eb;
}

#routrell-templates-ranking .btn-edit:hover {
    background: #ffedd5;
    border-color: #ea580c;
    color: #ea580c;
}

#routrell-templates-ranking .btn-delete-template:hover {
    background: #fee2e2;
    border-color: #dc2626;
    color: #dc2626;
}

/* ============================================
   RESPONSIVO
   ============================================ */

@media (max-width: 768px) {
    #routrell-templates-ranking {
        padding: 16px;
    }

    #routrell-templates-ranking .templates-title {
        font-size: 1.5rem;
    }

    #routrell-templates-ranking .active-template-banner {
        flex-direction: column;
        text-align: center;
    }

    #routrell-templates-ranking .templates-actions-bar {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    #routrell-templates-ranking .btn-new-template {
        justify-content: center;
    }

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

    #routrell-templates-ranking .template-card-actions {
        justify-content: center;
    }

    #routrell-templates-ranking .delete-confirmation-content {
        flex-direction: column;
        text-align: center;
    }

    #routrell-templates-ranking .delete-confirmation-actions {
        width: 100%;
        justify-content: center;
    }

    #routrell-templates-ranking .template-form-footer {
        flex-direction: column;
    }

    #routrell-templates-ranking .template-form-footer button {
        width: 100%;
        justify-content: center;
    }
}