/* ============================================
   SyncIMAPWeb - Estilo Soltia
   Colores: #BB4C81 (primario), #E7324C (secundario), #2E0547 (texto)
   Tipografía: Nunito Sans
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700;900&display=swap');

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

body {
    font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #2E0547 0%, #BB4C81 100%);
    min-height: 100vh;
    padding: 20px;
    color: #2E0547;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    background: white;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(46, 5, 71, 0.25);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #2E0547 0%, #4a1a5e 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

.logo {
    max-width: 150px;
    height: auto;
    margin-bottom: 15px;
}

header h1 {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 8px;
}

.subtitle {
    opacity: 0.85;
    font-size: 1rem;
    font-weight: 500;
}

form {
    padding: 30px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

.form-section {
    background: #faf7fb;
    padding: 20px;
    border-radius: 4px;
    border: 1px solid #e8dced;
}

.form-section h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #2E0547;
    border-bottom: 2px solid #BB4C81;
    padding-bottom: 10px;
}

.provider-select {
    margin-bottom: 15px;
}

.provider-select label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #2E0547;
}

.provider-select select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e8dced;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    cursor: pointer;
    color: #2E0547;
}

.provider-select select:focus {
    outline: none;
    border-color: #BB4C81;
    box-shadow: 0 0 0 2px rgba(187, 76, 129, 0.15);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #2E0547;
    font-size: 0.9rem;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e8dced;
    border-radius: 4px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
    color: #2E0547;
}

.form-group input:focus {
    outline: none;
    border-color: #BB4C81;
    box-shadow: 0 0 0 2px rgba(187, 76, 129, 0.15);
}

.form-group input::placeholder {
    color: #a89aad;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #BB4C81;
}

.checkbox-group label {
    margin-bottom: 0;
    cursor: pointer;
    font-weight: 500;
}

.provider-hint {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.85rem;
}

.provider-hint a {
    color: #BB4C81;
    font-weight: 600;
}

.provider-hint a:hover {
    color: #E7324C;
}

/* Opciones avanzadas */
.advanced-section {
    margin-top: 20px;
}

.advanced-section details {
    background: #fef8e7;
    border: 1px solid #f0d68a;
    border-radius: 4px;
    padding: 15px;
}

.advanced-section summary {
    cursor: pointer;
    font-weight: 700;
    color: #8a6d0f;
}

.advanced-options {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #f0d68a;
}

/* Historial */
.history-section {
    margin-top: 20px;
    padding: 20px;
    background: #f5eef8;
    border-radius: 4px;
    border: 1px solid #d9c8e0;
}

.history-section h3 {
    margin-bottom: 15px;
    color: #2E0547;
    font-size: 1rem;
}

#historyList {
    margin-bottom: 15px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: white;
    border-radius: 4px;
    margin-bottom: 8px;
    border: 1px solid #d9c8e0;
}

.history-item-info {
    flex: 1;
}

.history-item-info strong {
    color: #2E0547;
}

.history-item-info small {
    display: block;
    color: #666;
}

.history-item button {
    padding: 6px 12px;
    background: #BB4C81;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.history-item button:hover {
    background: #a3426f;
}

/* Botones y acciones */
.form-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e8dced;
}

.btn-primary,
.btn-secondary {
    padding: 12px 28px;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: #a3426f;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(187, 76, 129, 0.35);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #f5eef8;
    color: #2E0547;
    border: 1px solid #d9c8e0;
}

.btn-secondary:hover {
    background: #ebe0f0;
    border-color: #BB4C81;
}

/* Sección de resultados */
.result-section {
    margin: 0 30px 30px;
    padding: 20px;
    background: #2E0547;
    border-radius: 4px;
}

.result-section h3 {
    color: #4ade80;
    margin-bottom: 15px;
    font-weight: 700;
}

#resultOutput {
    background: #1a0329;
    color: #e8dced;
    padding: 15px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
}

/* Sección de información */
.info-section {
    padding: 30px;
    background: #faf7fb;
}

.info-section h3 {
    margin-bottom: 20px;
    color: #2E0547;
    font-weight: 700;
}

.info-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .info-cards {
        grid-template-columns: 1fr;
    }
}

.info-card {
    background: white;
    padding: 20px;
    border-radius: 4px;
    border: 1px solid #e8dced;
}

.info-card h4 {
    margin-bottom: 10px;
    color: #2E0547;
    font-weight: 700;
}

.info-card p {
    margin-bottom: 10px;
    color: #666;
    font-size: 0.9rem;
}

.info-card ol {
    margin-left: 20px;
    color: #666;
    font-size: 0.85rem;
}

.info-card ol li {
    margin-bottom: 5px;
}

footer {
    padding: 20px 30px;
    text-align: center;
    background: #2E0547;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* Loading animation */
.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-loading::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Progress indicator */
.progress-container {
    margin: 20px 30px;
    display: none;
}

.progress-bar {
    height: 20px;
    background: #e8dced;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #BB4C81, #E7324C);
    width: 0%;
    transition: width 0.3s;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    color: #2E0547;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ============================================
   MODAL DE HISTORIAL
   ============================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(46, 5, 71, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 4px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(46, 5, 71, 0.4);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e8dced;
    background: linear-gradient(135deg, #2E0547 0%, #4a1a5e 100%);
    border-radius: 4px 4px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: white;
    font-size: 1.3rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: white;
    opacity: 0.8;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.modal-disclaimer {
    padding: 12px 25px;
    background: #f5eef8;
    color: #BB4C81;
    font-size: 0.9rem;
    font-weight: 500;
    border-bottom: 1px solid #e8dced;
}

.modal-body {
    padding: 20px 25px;
    overflow-y: auto;
    flex: 1;
}

#historyEmpty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

#historyEmpty p {
    font-size: 1rem;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px;
    background: #faf7fb;
    border-radius: 4px;
    margin-bottom: 12px;
    border: 1px solid #e8dced;
    transition: border-color 0.2s;
}

.history-item:hover {
    border-color: #BB4C81;
}

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

.history-item-title {
    font-weight: 700;
    color: #2E0547;
    font-size: 1rem;
    margin-bottom: 6px;
    word-break: break-word;
}

.history-item-details {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: #666;
}

.history-date {
    background: #e8dced;
    padding: 2px 8px;
    border-radius: 4px;
    color: #2E0547;
}

.history-servers {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
}

.history-item-provider {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #666;
}

.provider-badge {
    background: #BB4C81;
    color: white;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.history-item-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-left: 15px;
}

.btn-load {
    padding: 8px 16px;
    background: #BB4C81;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 700;
    transition: background 0.2s;
}

.btn-load:hover {
    background: #a3426f;
}

.btn-delete-item {
    padding: 6px 12px;
    background: transparent;
    color: #E7324C;
    border: 1px solid #E7324C;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-delete-item:hover {
    background: #E7324C;
    color: white;
}

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 15px 25px;
    border-top: 1px solid #e8dced;
    background: #faf7fb;
    border-radius: 0 0 4px 4px;
    flex-wrap: wrap;
}

.btn-copy {
    padding: 10px 20px;
    background: #198754;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: background 0.2s;
}

.btn-copy:hover {
    background: #157347;
}

.btn-danger {
    padding: 10px 20px;
    background: #E7324C;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 700;
    transition: background 0.2s;
}

.btn-danger:hover {
    background: #c92a40;
}

@media (max-width: 600px) {
    .modal-content {
        max-height: 95vh;
    }

    .history-item {
        flex-direction: column;
    }

    .history-item-actions {
        flex-direction: row;
        margin-left: 0;
        margin-top: 12px;
        width: 100%;
    }

    .history-item-actions button {
        flex: 1;
    }

    .modal-footer {
        justify-content: center;
    }

    .modal-footer button {
        flex: 1;
        min-width: 100px;
    }
}

/* ============================================
   PESTAÑAS PRINCIPALES
   ============================================ */
.tabs {
    display: flex;
    background: #faf7fb;
    border-bottom: 1px solid #e8dced;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 700;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    font-family: inherit;
}

.tab-btn:hover {
    color: #2E0547;
    background: #f5eef8;
}

.tab-btn.active {
    color: #BB4C81;
    background: white;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #BB4C81, #E7324C);
}

.tab-content {
    display: none;
}

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

/* ============================================
   MIGRACIÓN MÚLTIPLE
   ============================================ */
#tab-batch form {
    padding: 30px;
}

.batch-servers {
    margin-bottom: 25px;
}

.batch-input-section {
    background: #faf7fb;
    border-radius: 4px;
    padding: 25px;
    margin-bottom: 20px;
    border: 1px solid #e8dced;
}

.batch-input-section h3 {
    margin-bottom: 8px;
    color: #2E0547;
    font-size: 1.2rem;
    font-weight: 700;
}

.batch-description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* Sub-pestañas para modos de entrada */
.input-mode-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.input-mode-btn {
    padding: 10px 20px;
    border: 1px solid #e8dced;
    background: white;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 700;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.input-mode-btn:hover {
    border-color: #BB4C81;
    color: #BB4C81;
}

.input-mode-btn.active {
    background: #BB4C81;
    color: white;
    border-color: #BB4C81;
}

.input-mode-content {
    display: none;
}

.input-mode-content.active {
    display: block;
}

/* Instrucciones de uso */
.batch-instructions {
    background: #f5eef8;
    border: 1px solid #d9c8e0;
    border-radius: 4px;
    padding: 15px 20px;
    margin-bottom: 20px;
}

.batch-instructions p {
    margin-bottom: 10px;
    color: #2E0547;
}

.batch-instructions ul {
    margin: 0;
    padding-left: 20px;
    color: #666;
    font-size: 0.9rem;
}

.batch-instructions li {
    margin-bottom: 5px;
}

/* Label opcional */
.optional-label {
    font-weight: 500;
    color: #666;
    font-size: 0.85rem;
}

/* Formulario para añadir cuentas */
.add-account-form {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.add-account-form .form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.btn-add-account {
    padding: 10px 25px;
    background: #198754;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.btn-add-account:hover {
    background: #157347;
}

/* Área de pegar texto */
.paste-area > label {
    display: block;
    margin-bottom: 10px;
    font-weight: 700;
    color: #2E0547;
}

.paste-area code {
    background: #e8dced;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #2E0547;
}

.paste-format-help {
    background: white;
    border: 1px solid #e8dced;
    border-radius: 4px;
    padding: 12px 15px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.paste-format-help p {
    margin: 0 0 8px 0;
    color: #2E0547;
    font-weight: 600;
}

.paste-format-help code {
    background: #2E0547;
    color: #4ade80;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.format-desc {
    color: #666;
    font-size: 0.85rem;
    margin-left: 8px;
}

.paste-area textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #e8dced;
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: 'Monaco', 'Menlo', monospace;
    resize: vertical;
    transition: all 0.2s;
    color: #2E0547;
}

.paste-area textarea:focus {
    outline: none;
    border-color: #BB4C81;
    box-shadow: 0 0 0 2px rgba(187, 76, 129, 0.15);
}

.paste-area textarea::placeholder {
    color: #a89aad;
}

.btn-parse-accounts {
    margin-top: 15px;
    padding: 10px 25px;
    background: #BB4C81;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-parse-accounts:hover {
    background: #a3426f;
}

/* Lista de cuentas añadidas */
.accounts-list-container {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e8dced;
}

.accounts-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.accounts-list-header h4 {
    margin: 0;
    color: #2E0547;
    font-size: 1rem;
    font-weight: 700;
}

.accounts-list-header h4 span {
    background: #BB4C81;
    color: white;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.btn-clear-accounts {
    padding: 6px 15px;
    background: transparent;
    color: #E7324C;
    border: 1px solid #E7324C;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear-accounts:hover {
    background: #E7324C;
    color: white;
}

.accounts-list {
    max-height: 250px;
    overflow-y: auto;
    background: white;
    border-radius: 4px;
    border: 1px solid #e8dced;
}

.no-accounts {
    padding: 30px;
    text-align: center;
    color: #666;
    font-size: 0.95rem;
}

.account-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #e8dced;
    transition: background 0.2s;
}

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

.account-item:hover {
    background: #faf7fb;
}

.account-user {
    flex: 1;
    font-weight: 600;
    color: #2E0547;
    word-break: break-all;
}

.account-pass-hint {
    font-size: 0.8rem;
    margin: 0 15px;
}

.pass-same {
    background: #d1e7dd;
    color: #0f5132;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: 600;
}

.pass-different {
    background: #fff3cd;
    color: #664d03;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: 600;
}

.btn-remove-account {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    color: #E7324C;
    border: 1px solid #E7324C;
    border-radius: 4px;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-remove-account:hover {
    background: #E7324C;
    color: white;
}

/* Progreso de migración múltiple */
.batch-progress {
    margin-bottom: 20px;
}

.batch-progress .progress-bar {
    height: 25px;
    margin-bottom: 10px;
}

.batch-progress .progress-text {
    font-weight: 600;
}

#batchResultOutput {
    background: #1a0329;
    color: #e8dced;
    padding: 15px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 500px;
    overflow-y: auto;
}

/* Responsive para migración múltiple */
@media (max-width: 768px) {
    .add-account-form {
        flex-direction: column;
    }

    .add-account-form .form-group {
        width: 100%;
    }

    .btn-add-account {
        width: 100%;
    }

    .input-mode-tabs {
        flex-direction: column;
    }

    .input-mode-btn {
        text-align: center;
    }

    .accounts-list-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
}
