* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 25px;
    text-align: center;
    border-left: 4px solid #9b59b6;
}

header h1 {
    color: #2C3E50;
    margin-bottom: 10px;
}

.subtitle {
    color: #7f8c8d;
}

/* Step Cards */
.step-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.step-card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.step-card.disabled .step-number {
    background: #bdc3c7;
}

.step-card.active {
    border-left: 4px solid #9b59b6;
}

.step-card.completed {
    border-left: 4px solid #27ae60;
}

.step-card.completed .step-number {
    background: #27ae60;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.step-number {
    width: 36px;
    height: 36px;
    background: #9b59b6;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 1.1em;
}

.step-header h2 {
    flex: 1;
    color: #2C3E50;
    font-size: 1.2em;
    margin: 0;
}

.step-actions {
    display: flex;
    gap: 10px;
}

.step-content {
    padding: 25px;
}

.step-description {
    color: #666;
    margin-bottom: 20px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #2C3E50;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    font-size: 0.95em;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.2);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: #9b59b6;
}

.btn-primary:hover:not(:disabled) {
    background: #8e44ad;
}

.btn-success {
    background: #27ae60;
}

.btn-success:hover:not(:disabled) {
    background: #1e8449;
}

.btn-secondary {
    background: #95a5a6;
}

.btn-secondary:hover:not(:disabled) {
    background: #7f8c8d;
}

.btn-large {
    padding: 15px 35px;
    font-size: 1.1em;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85em;
}

/* Stats inline */
.stats-inline {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    padding: 15px 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #9b59b6;
}

.stat-label {
    font-size: 0.85em;
    color: #666;
}

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

/* Email Cards */
.email-card {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.email-card:hover {
    border-color: #9b59b6;
    box-shadow: 0 4px 15px rgba(155, 89, 182, 0.15);
}

.email-card.selected {
    background: #f3e5f5;
    border-color: #9b59b6;
    box-shadow: 0 4px 20px rgba(155, 89, 182, 0.25);
}

.email-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #2C3E50;
    color: white;
}

.email-card.selected .email-card-header {
    background: #9b59b6;
}

.email-card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.email-icon {
    font-size: 1.3em;
}

.email-card-check {
    width: 26px;
    height: 26px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.email-card.selected .email-card-check {
    background: white;
    color: #9b59b6;
}

.email-card-section {
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.email-card-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 10px;
    font-weight: 600;
}

.product-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.product-chip {
    background: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    color: #2C3E50;
    border: 1px solid #e0e0e0;
}

.product-chip .precio {
    color: #27ae60;
    font-weight: 600;
    margin-left: 6px;
}

.client-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.client-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
}

.client-name {
    font-weight: 600;
    color: #2C3E50;
}

.client-email {
    font-size: 0.85em;
    color: #666;
}

/* Barra de idioma automatico */
.auto-lang-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f3e5f5;
    border: 1px solid #ce93d8;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    color: #4a148c;
    font-size: 0.9em;
}

.auto-lang-icon {
    font-size: 1.2em;
    flex-shrink: 0;
}

.preview-lang-selector {
    margin-left: auto;
}

/* Language Selector */
.language-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-option:hover {
    background: #eef2f7;
}

.lang-option input[type="radio"] {
    display: none;
}

.lang-option:has(input:checked) {
    background: #f3e5f5;
    border-color: #9b59b6;
}

.lang-option span {
    font-size: 0.95em;
    color: #2C3E50;
}

/* Preview Section */
.preview-section {
    background: #f8f9fa;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 25px;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #2C3E50;
    color: white;
}

.preview-header h3 {
    margin: 0;
    font-size: 1em;
}

.preview-client {
    font-size: 0.9em;
    opacity: 0.8;
}

.preview-content {
    padding: 25px;
    min-height: 200px;
    white-space: pre-wrap;
    line-height: 1.8;
    font-size: 0.95em;
}

.preview-content .product-line {
    padding: 8px 12px;
    background: white;
    border-radius: 5px;
    margin: 5px 0;
    border-left: 3px solid #9b59b6;
}

/* Send Section */
.send-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.send-info {
    color: #666;
    font-size: 0.95em;
}

/* Messages */
.message-container {
    margin-top: 20px;
}

.message {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.message-success {
    background: #d5f4e6;
    border-left: 4px solid #27ae60;
    color: #155724;
}

.message-error {
    background: #f8d7da;
    border-left: 4px solid #e74c3c;
    color: #721c24;
}

.message-info {
    background: #e3f2fd;
    border-left: 4px solid #3498db;
    color: #0c5460;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    overflow-y: auto;
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 10px;
    padding: 25px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
}

.modal-header h3 {
    color: #2C3E50;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    margin-bottom: 20px;
}

.modal-body ul {
    list-style: none;
    padding: 0;
    margin-top: 15px;
}

.modal-body li {
    padding: 0;
    background: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 5px;
}

.destinatario-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.2s;
    width: 100%;
}

.destinatario-label:hover {
    background: #eaf4fb;
}

.destinatario-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #9b59b6;
    flex-shrink: 0;
}

.destinatario-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    gap: 10px;
}

.destinatario-nombre {
    font-weight: 600;
    color: #2C3E50;
}

.modal-body li .email {
    color: #666;
    font-size: 0.9em;
}

.lang-tag {
    margin-left: auto;
    flex-shrink: 0;
    background: #9b59b6;
    color: white;
    font-size: 0.75em;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

/* Destinatario desmarcado */
.destinatario-label:has(.destinatario-check:not(:checked)) {
    opacity: 0.45;
    text-decoration: line-through;
    background: #f0f0f0;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

/* Empty message */
.empty-message {
    text-align: center;
    color: #999;
    padding: 40px;
}

/* Stat enviados */
.stat-item.stat-enviados .stat-value {
    color: #27ae60;
}

/* Historial Section */
.historial-section {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 30px;
    overflow: hidden;
    border-left: 4px solid #27ae60;
}

.historial-header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.historial-header-section h2 {
    margin: 0;
    color: #2C3E50;
    font-size: 1.2em;
}

.historial-subtitle {
    color: #666;
    font-size: 0.9em;
}

.historial-acciones {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.historial-filtros {
    display: flex;
    gap: 8px;
}

.historial-sel-btns {
    display: flex;
    gap: 8px;
    align-items: center;
}

.btn-filtro {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: white;
    color: #666;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-filtro:hover {
    border-color: #9b59b6;
    color: #9b59b6;
}

.btn-filtro.active {
    background: #9b59b6;
    color: white;
    border-color: #9b59b6;
}

.historial-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

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

.historial-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border-left: 3px solid #27ae60;
}

.historial-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eef2f6;
}

.historial-fecha {
    font-size: 0.9em;
    color: #666;
}

.historial-badge {
    background: #27ae60;
    color: white;
    padding: 3px 11px;
    border-radius: 12px;
    font-size: 0.78em;
    font-weight: 600;
}

.historial-productos {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
}

.historial-chip {
    background: white;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 0.75em;
    color: #2C3E50;
    border: 1px solid #e0e0e0;
}

.historial-destinatarios {
    font-size: 0.85em;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Selección de historial */
.btn-sel {
    padding: 5px 14px;
    border: 1px solid #9b59b6;
    border-radius: 20px;
    background: white;
    color: #9b59b6;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sel:hover {
    background: #9b59b6;
    color: white;
}

.btn-eliminar-sel {
    padding: 5px 14px;
    border: 1px solid #e74c3c;
    border-radius: 20px;
    background: #e74c3c;
    color: white;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-eliminar-sel:hover {
    background: #c0392b;
    border-color: #c0392b;
}

.btn-cancelar-sel {
    padding: 5px 14px;
    border: 1px solid #95a5a6;
    border-radius: 20px;
    background: white;
    color: #7f8c8d;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cancelar-sel:hover {
    background: #ecf0f1;
}

.historial-card.seleccionable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.historial-card.seleccionable:hover {
    border-left-color: #9b59b6;
    box-shadow: 0 0 0 2px rgba(155, 89, 182, 0.2);
}

.historial-card.seleccionada {
    border-left-color: #e74c3c;
    background: #fdf2f0;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.25);
}

.historial-check-wrap {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.historial-check {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: #e74c3c;
    cursor: pointer;
}

/* Loading */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #9b59b6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .clients-grid {
        grid-template-columns: 1fr;
    }

    .stats-inline {
        flex-wrap: wrap;
        justify-content: center;
    }

    .step-header {
        flex-wrap: wrap;
    }

    .step-actions {
        width: 100%;
        margin-top: 10px;
    }

    .language-selector {
        flex-direction: column;
    }

    .send-section {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}
