/**
 * WebMail v58.0 - Estilos principales
 * Cliente de correo completo con carpetas limpias y selección persistente
 */

/* ============================================================================
   RESET Y ESTILOS BASE
   ============================================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================================
   LAYOUT PRINCIPAL
   ============================================================================ */

.container {
    display: flex;
    height: 100vh;
}

/* Panel de carpetas (izquierdo) */
.folders-panel {
    width: 260px;
    background: linear-gradient(135deg, #2c3e50, #1a252f);
    color: white;
    overflow-y: auto;
    flex-shrink: 0;
}

.folders-header {
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
}

.folders-header h2 {
    font-size: 18px;
    margin-bottom: 15px;
}

.version-badge {
    font-size: 10px;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 5px;
}

.btn-header {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

/* Botones generales */
.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn-purple {
    background: #8e44ad;
    color: white;
}

.btn-orange {
    background: #fd7e14;
    color: white;
}

.btn-blue {
    background: #3498db;
    color: white;
}

.btn-green {
    background: #27ae60;
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* Lista de carpetas */
.folder-list {
    list-style: none;
    padding: 10px 0;
}

.folder-item {
    padding: 12px 20px;
    cursor: pointer;
    border-left: 3px solid transparent;
    display: flex;
    gap: 10px;
    transition: all 0.2s ease;
}

.folder-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Carpeta activa */
.folder-item.active {
    background: rgba(52, 152, 219, 0.35);
    border-left: 3px solid #3498db;
    font-weight: 600;
    position: relative;
}

/* Indicador de carpeta activa */
.folder-item.active::after {
    content: "📍";
    position: absolute;
    right: 15px;
    font-size: 12px;
    opacity: 0.8;
}

/* ============================================================================
   PANEL DE EMAILS (central)
   ============================================================================ */

.emails-panel {
    width: 480px;
    background: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #dee2e6;
    flex-shrink: 0;
}

.emails-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.search-bar {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.search-bar input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.search-bar input:focus {
    outline: none;
    border-color: #3498db;
}

.search-bar select,
.search-bar button {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
}

.email-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 13px;
}

.pagination {
    display: flex;
    gap: 5px;
    align-items: center;
}

.pagination button {
    padding: 4px 10px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination button:hover:not(:disabled) {
    background: #e9ecef;
}

.pagination button.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Lista de emails */
.emails-list {
    flex: 1;
    overflow-y: auto;
}

.email-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: background 0.2s ease;
}

.email-item:hover {
    background: #f8f9fa;
}

.email-item.unread {
    background: #fff3e0;
    font-weight: bold;
}

/* Email seleccionado */
.email-item.selected {
    background: #e3f2fd !important;
    border-left: 3px solid #2196f3;
    position: relative;
    box-shadow: inset 0 0 0 1px rgba(33, 150, 243, 0.15);
}

.email-item.selected.unread {
    background: #fff8e1 !important;
    border-left-color: #ff9800;
}

.email-item.selected:hover {
    background: #bbdef5 !important;
}

.email-item.selected.unread:hover {
    background: #ffe0b2 !important;
}

.email-from {
    font-size: 14px;
    font-weight: 500;
}

.email-subject {
    font-size: 13px;
    margin-top: 3px;
    color: #495057;
}

.email-date {
    font-size: 11px;
    color: #6c757d;
    margin-top: 3px;
}

/* ============================================================================
   PANEL DE CONTENIDO (derecho)
   ============================================================================ */

.content-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-header {
    padding: 15px 20px;
    background: white;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tools-bar {
    display: flex;
    gap: 10px;
}

.tools-bar button {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    transition: all 0.2s ease;
}

.tools-bar button:hover {
    opacity: 0.85;
}

.btn-contacts { background: #3498db; }
.btn-tasks { background: #27ae60; }
.btn-notes { background: #fd7e14; }

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* ============================================================================
   MODALES
   ============================================================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 800px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
}

.modal-sat {
    width: 900px;
}

.modal-header {
    background: #2c3e50;
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal-btn {
    cursor: pointer;
    font-size: 28px;
    line-height: 1;
}

.close-modal-btn:hover {
    opacity: 0.8;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ============================================================================
   FORMULARIOS
   ============================================================================ */

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 5px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
}

.help-text {
    display: block;
    color: #666;
    margin-top: 5px;
    font-size: 12px;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* ============================================================================
   TABS
   ============================================================================ */

.tab-bar {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tab {
    padding: 10px 20px;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.tab:hover {
    background: #f8f9fa;
}

.tab.active {
    border-bottom: 2px solid #007bff;
    color: #007bff;
    font-weight: bold;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================================================
   LISTAS DE DATOS
   ============================================================================ */

.data-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 6px;
}

.data-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.data-item:last-child {
    border-bottom: none;
}

.empty-list {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.btn-delete-item {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.btn-delete-item:hover {
    background: #c82333;
}

/* ============================================================================
   TOAST NOTIFICATIONS
   ============================================================================ */

.toast-message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast-message.error {
    background: #dc3545;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================================================
   GESTIÓN DE CARPETAS
   ============================================================================ */

.folders-list-container {
    border: 1px solid #ddd;
    border-radius: 6px;
    max-height: 400px;
    overflow-y: auto;
}

.folder-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
}

.folder-list-item:last-child {
    border-bottom: none;
}

.folder-actions {
    display: flex;
    gap: 8px;
}

.folder-actions button {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.btn-empty-folder {
    background: #ffc107;
    color: #333;
}

.btn-empty-folder:hover {
    background: #e0a800;
}

.btn-delete-folder {
    background: #dc3545;
    color: white;
}

.btn-delete-folder:hover {
    background: #c82333;
}

.create-folder-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.create-folder-box input {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* ============================================================================
   MENSAJES DE ESTADO
   ============================================================================ */

.loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.error {
    color: #721c24;
    background: #f8d7da;
    padding: 10px;
    border-radius: 6px;
    margin: 10px;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 6px;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 6px;
}

.info-box {
    background: #e7f3ff;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.no-config-message {
    text-align: center;
    padding: 40px;
    background: #fff3cd;
    border-radius: 12px;
    margin: 20px;
}

.no-config-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.test-result-container {
    margin-top: 10px;
}

.test-result {
    margin-left: 10px;
}

/* ============================================================================
   SECCIONES Y DIVISORES
   ============================================================================ */

.section-divider {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.section-divider h4 {
    margin-bottom: 15px;
}

/* ============================================================================
   ATTACHMENTS
   ============================================================================ */

.attachment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.attachment-item:last-child {
    border-bottom: none;
}

.remove-attachment {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

/* ============================================================================
   EMAIL CONTENT
   ============================================================================ */

.email-content {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
}

/* ============================================================================
   SCROLLBARS PERSONALIZADOS
   ============================================================================ */

.folders-panel::-webkit-scrollbar {
    width: 6px;
}

.folders-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.folders-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.folders-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.emails-list::-webkit-scrollbar {
    width: 8px;
}

.emails-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.emails-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.emails-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.content-body::-webkit-scrollbar {
    width: 8px;
}

.content-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.content-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.content-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ============================================================================
   MEDIA QUERIES
   ============================================================================ */

@media (max-width: 768px) {
    .folders-panel {
        width: 200px;
    }
    
    .emails-panel {
        width: 350px;
    }
    
    .btn-header {
        flex-direction: column;
    }
    
    .tools-bar {
        flex-direction: column;
        gap: 5px;
    }
}

@media print {
    .folders-panel,
    .emails-panel,
    .reply-btn,
    .replyall-btn,
    .forward-btn,
    #moveFolderSelect,
    #moveEmailBtn,
    #extractSatBtn,
    #exportPdfBtn,
    .download-attachment-btn,
    [class*="btn"],
    .tools-bar,
    .pagination {
        display: none !important;
    }
    
    .content-panel {
        width: 100% !important;
    }
    
    .email-content {
        border: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    @page {
        margin: 2cm;
    }
}