/**
 * Stili modulo Comunicazioni
 *
 * @package Medaid
 * @subpackage Comunicazioni
 */

/* Dashboard Stats */
.comunicazioni-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--card-bg, #fff);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-card .stat-icon.sent {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.stat-card .stat-icon.failed {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.stat-card .stat-icon.queued {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.stat-card .stat-icon.workflows {
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.stat-card .stat-content {
    flex: 1;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary, #1f2937);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 0.25rem;
}

/* SMTP Configuration */
.smtp-form {
    max-width: 600px;
}

.smtp-provider-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    padding-bottom: 0.5rem;
}

.provider-tab {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    transition: all 0.2s;
}

.provider-tab:hover {
    background: var(--hover-bg, #f3f4f6);
}

.provider-tab.active {
    background: var(--primary-color, #4f46e5);
    color: white;
}

.smtp-test-result {
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.smtp-test-result.success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.smtp-test-result.error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Workflows List */
.workflows-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.workflow-card {
    background: var(--card-bg, #fff);
    border-radius: 0.75rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}

.workflow-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

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

.workflow-icon {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.workflow-info {
    flex: 1;
    min-width: 0;
}

.workflow-name {
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    margin-bottom: 0.25rem;
}

.workflow-trigger {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.workflow-trigger .badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.workflow-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.workflow-actions-count {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
}

.workflow-toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.workflow-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.workflow-toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    transition: 0.3s;
    border-radius: 24px;
}

.workflow-toggle .slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.workflow-toggle input:checked + .slider {
    background-color: #10b981;
}

.workflow-toggle input:checked + .slider:before {
    transform: translateX(20px);
}

/* Workflow Editor */
.workflow-editor {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .workflow-editor {
        grid-template-columns: 1fr;
    }
}

.workflow-form {
    background: var(--card-bg, #fff);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.workflow-sidebar {
    position: sticky;
    top: 1rem;
}

.event-selector {
    display: grid;
    gap: 0.5rem;
}

.event-option {
    padding: 1rem;
    border: 2px solid var(--border-color, #e5e7eb);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.event-option:hover {
    border-color: var(--primary-color, #4f46e5);
}

.event-option.selected {
    border-color: var(--primary-color, #4f46e5);
    background: rgba(79, 70, 229, 0.05);
}

.event-option .event-name {
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    margin-bottom: 0.25rem;
}

.event-option .event-description {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
}

/* Actions Builder */
.actions-builder {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
    padding-top: 1.5rem;
}

.actions-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.action-item {
    background: var(--bg-secondary, #f9fafb);
    border-radius: 0.5rem;
    padding: 1rem;
    position: relative;
}

.action-item .action-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.action-item .action-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color, #4f46e5);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

.action-item .action-type {
    font-weight: 500;
    flex: 1;
}

.action-item .action-remove {
    padding: 0.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    border-radius: 0.25rem;
}

.action-item .action-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.action-fields {
    display: grid;
    gap: 1rem;
}

.add-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px dashed var(--border-color, #e5e7eb);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.add-action-btn:hover {
    border-color: var(--primary-color, #4f46e5);
    color: var(--primary-color, #4f46e5);
}

/* Conditions Builder */
.conditions-builder {
    margin-top: 1.5rem;
}

.condition-row {
    display: grid;
    grid-template-columns: 1fr 120px 1fr auto;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.condition-row select,
.condition-row input {
    padding: 0.5rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* Templates List */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.template-card {
    background: var(--card-bg, #fff);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s;
}

.template-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.template-card .template-preview {
    height: 120px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

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

.template-card .template-name {
    font-weight: 600;
    color: var(--text-primary, #1f2937);
    margin-bottom: 0.25rem;
}

.template-card .template-subject {
    font-size: 0.875rem;
    color: var(--text-secondary, #6b7280);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-card .template-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.template-card .template-category {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
}

.template-card.system .template-preview {
    background: linear-gradient(135deg, #6b7280 0%, #374151 100%);
}

/* Template Editor */
.template-editor-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    min-height: 500px;
}

@media (max-width: 1200px) {
    .template-editor-container {
        grid-template-columns: 1fr;
    }
}

.template-editor {
    display: flex;
    flex-direction: column;
}

.template-editor textarea {
    flex: 1;
    min-height: 400px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    padding: 1rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0.5rem;
    resize: vertical;
}

.template-preview-frame {
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0.5rem;
    background: white;
    overflow: hidden;
}

.template-preview-frame iframe {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border: none;
}

/* Placeholders Panel */
.placeholders-panel {
    background: var(--card-bg, #fff);
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.placeholders-panel h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

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

.placeholder-tag {
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-family: monospace;
    cursor: pointer;
    transition: all 0.2s;
}

.placeholder-tag:hover {
    background: var(--primary-color, #4f46e5);
    color: white;
}

/* Email Log */
.email-log-table {
    width: 100%;
    border-collapse: collapse;
}

.email-log-table th,
.email-log-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
}

.email-log-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary, #6b7280);
    background: var(--bg-secondary, #f9fafb);
}

.email-log-table td {
    font-size: 0.875rem;
}

.email-log-table .status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.email-log-table .status-badge.sent {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
}

.email-log-table .status-badge.failed {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.email-log-table .status-badge.queued {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

/* Recipients Selector */
.recipients-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recipient-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.recipient-option:hover {
    border-color: var(--primary-color, #4f46e5);
}

.recipient-option.selected {
    border-color: var(--primary-color, #4f46e5);
    background: rgba(79, 70, 229, 0.05);
}

.recipient-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.recipient-option .recipient-info {
    flex: 1;
}

.recipient-option .recipient-name {
    font-weight: 500;
}

.recipient-option .recipient-desc {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

/* Delay Input */
.delay-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.delay-input input {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 0.375rem;
    text-align: center;
}

.delay-input span {
    color: var(--text-secondary, #6b7280);
    font-size: 0.875rem;
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary, #6b7280);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: var(--text-primary, #1f2937);
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* Chart Container */
.chart-container {
    background: var(--card-bg, #fff);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.chart-container h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Loading State */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color, #e5e7eb);
    border-top-color: var(--primary-color, #4f46e5);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
