/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.logo i {
    font-size: 2rem;
    color: #667eea;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: none !important;
    color: #333 !important;
    border-radius: 5px;
}

.user-info span {
    color: #333 !important;
    font-weight: 600;
    font-size: 1rem;
}

.user-info button, .user-info .btn-logout {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 0.25rem 0.7rem;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.95rem;
    margin-left: 0.5rem;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.user-info button:hover, .user-info .btn-logout:hover {
    background: rgba(255, 255, 255, 0.35);
}

.user-info .btn-logout {
    background: #667eea !important;
    color: #fff !important;
    border: none;
    font-weight: 500;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(102,126,234,0.08);
}

.user-info .btn-logout:hover {
    background: #4b5fc9 !important;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
    font-weight: 500;
}

.connection-status.connected {
    color: #10b981;
}

.connection-status.disconnected {
    color: #ef4444;
}

.connection-status.connecting {
    color: #f59e0b;
}

/* Navigation */
.nav-tabs {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0 2rem;
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.nav-tab {
    background: none;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    color: #6b7280;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.nav-tab:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.nav-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.content-header h2 {
    font-size: 1.875rem;
    font-weight: 600;
    color: white;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    text-decoration: none;
    font-size: 0.875rem;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.4);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.9);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

.btn-outline:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Templates Grid */
.templates-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.template-editor,
.template-preview {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.editor-header,
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.editor-actions {
    display: flex;
    gap: 0.5rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.3s ease;
}

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

.form-group textarea {
    resize: vertical;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Variables Help */
.variables-help {
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.variables-help h4 {
    margin-bottom: 0.75rem;
    color: #374151;
    font-size: 0.875rem;
}

.variables-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.variable-tag {
    background: #667eea;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
    cursor: pointer;
    transition: background 0.3s ease;
}

.variable-tag:hover {
    background: #5a67d8;
}

/* Preview */
.preview-content {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.5rem;
    min-height: 200px;
    font-family: Arial, sans-serif;
    line-height: 1.5;
}

.preview-placeholder {
    color: #9ca3af;
    font-style: italic;
    text-align: center;
    margin-top: 2rem;
}

.template-stats {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.875rem;
    color: #6b7280;
}

/* Saved Templates */
.saved-templates {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.templates-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.template-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.3s ease;
}

.template-card:hover {
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.template-card h4 {
    margin-bottom: 0.5rem;
    color: #374151;
}

.template-card p {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.template-card-actions {
    display: flex;
    gap: 0.5rem;
}

/* Users */
.users-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

.users-filters input,
.users-filters select {
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

.users-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
    justify-items: center;
}

.user-card {
    max-width: 370px;
    width: 100%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.08);
    padding: 1.5rem 1.2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 180px;
    transition: box-shadow 0.2s;
    position: relative;
}

.user-card:hover {
    box-shadow: 0 4px 24px rgba(102, 126, 234, 0.18);
}

.user-card .user-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.user-card .user-info-block {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    margin-bottom: 1.2rem;
}

.user-card .user-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: #222;
    margin-bottom: 0.1rem;
}

.user-card .user-email {
    font-size: 1rem;
    color: #444;
    word-break: break-all;
    margin-bottom: 0.1rem;
}

.user-card .user-org {
    font-size: 0.95rem;
    color: #888;
}

.user-card .user-status {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    padding: 0.3rem 0.9rem;
    border-radius: 999px;
    font-size: 0.95rem;
    font-weight: 600;
    background: #e0f7ef;
    color: #1abc9c;
}

.user-card .user-status.suspended {
    background: #ffeaea;
    color: #e74c3c;
}

.user-card .user-actions {
    margin-top: 1.2rem;
    display: flex;
    gap: 0.5rem;
}

.user-card .user-actions button {
    flex: 1;
    padding: 0.5rem 0.8rem;
    border-radius: 5px;
    border: none;
    background: #667eea;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.user-card .user-actions button:hover {
    background: #5a6fd8;
}

.user-card .user-actions .btn-view-signature i {
    color: #fff !important;
}

/* Bulk Operations */
.bulk-operations {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.bulk-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e5e7eb;
}

.bulk-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.bulk-section h3 {
    margin-bottom: 1rem;
    color: #374151;
}

.user-selection {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.users-checklist {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
}

.user-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.3s ease;
}

.user-checkbox:hover {
    background: #f3f4f6;
}

.user-checkbox input[type="checkbox"] {
    width: auto;
}

.bulk-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
}

.bulk-results {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #e5e7eb;
}

/* Settings */
.settings-sections {
    display: grid;
    gap: 2rem;
}

.settings-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.settings-section h3 {
    margin-bottom: 1rem;
    color: #374151;
}

.config-status {
    display: grid;
    gap: 1rem;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
}

.config-item i {
    font-size: 1.25rem;
}

.config-item.success {
    background: #d1fae5;
    color: #065f46;
}

.config-item.error {
    background: #fee2e2;
    color: #991b1b;
}

.config-item.warning {
    background: #fef3c7;
    color: #92400e;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 25px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: scale(0.9) translateY(-20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    text-align: center;
    color: #667eea;
}

.loading-spinner i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.loading-spinner p {
    font-size: 1.125rem;
    font-weight: 500;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #667eea;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: toastSlideIn 0.3s ease;
}

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

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.warning {
    border-left-color: #f59e0b;
}

.toast-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b7280;
    margin-left: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        padding: 0 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .nav-tabs {
        padding: 0 1rem;
        overflow-x: auto;
    }

    .main-content {
        padding: 1rem;
    }

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

    .content-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .users-filters {
        flex-direction: column;
    }

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

    .modal {
        width: 95%;
        margin: 1rem;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

.hidden { display: none !important; }
.visible { display: block !important; }

.user-card,
.user-card * {
    color: #222 !important;
}

.user-card .user-status {
    color: #1abc9c !important;
    background: #e0f7ef !important;
}

.user-card .user-status.suspended {
    color: #e74c3c !important;
    background: #ffeaea !important;
}

.user-card .user-actions button {
    color: #fff !important;
}

#bulk-template-select {
    width: 100%;
    max-width: 320px;
    padding: 0.7rem 2.5rem 0.7rem 1rem;
    font-size: 1.05rem;
    border: 1.5px solid #667eea;
    border-radius: 8px;
    background: #f7f8fc url("data:image/svg+xml,%3Csvg width='16' height='16' fill='gray' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%23667eea' stroke-width='2' fill='none' fill-rule='evenodd'/%3E%3C/svg%3E") no-repeat right 1rem center/1.2em;
    color: #333;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border 0.2s;
    box-shadow: 0 2px 8px rgba(102,126,234,0.04);
}

#bulk-template-select:focus {
    border-color: #4b5fc9;
    outline: none;
    background-color: #fff;
}

#cancel-edit-template-btn {
    display: none;
}

/* Estilos para a Limpeza de E-mails */
.email-cleanup-container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem;
}

.user-selection-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #4a5568;
    margin: 0.5rem 0;
}

.stat-label {
    font-size: 0.9rem;
    color: #718096;
    margin-bottom: 0.5rem;
}

.stat-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: rgba(102, 126, 234, 0.2);
    font-size: 3rem;
    z-index: 1;
}

.filters-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.filter-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 1rem;
}

.date-range-custom {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

#date-range:has(option[value="custom"]:checked) + .date-range-custom {
    display: grid;
}

.actions-section {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin: 2rem 0;
}

.results-section {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.results-container {
    margin-top: 1rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem;
}

.result-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.result-item .subject {
    font-weight: 500;
    color: #2d3748;
}

.result-item .date {
    font-size: 0.85rem;
    color: #718096;
}
