/**
 * TTT Chrome AI Translation - Frontend Styles
 * Estilos optimizados para rendimiento y accesibilidad WCAG 2.1 AA
 */

/* Botón de traducción principal */
.ttt-chrome-ai-btn {
    background: linear-gradient(135deg, #4285f4, #1a73e8);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(26, 115, 232, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px; /* WCAG touch target size */
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.ttt-chrome-ai-btn:hover,
.ttt-chrome-ai-btn:focus {
    background: linear-gradient(135deg, #1a73e8, #1557b0);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.4);
    outline: 2px solid #4285f4;
    outline-offset: 2px;
}

.ttt-chrome-ai-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(26, 115, 232, 0.3);
}

.ttt-chrome-ai-btn::before {
    content: "🌐";
    font-size: 16px;
}

/* Estilos específicos para admin de WordPress */
.wp-admin .ttt-chrome-ai-btn {
    background: #0073aa;
    color: white;
    border: 1px solid #0073aa;
    padding: 8px 16px;
    font-size: 13px;
    margin: 10px 0;
    display: inline-block;
}

.wp-admin .ttt-chrome-ai-btn:hover,
.wp-admin .ttt-chrome-ai-btn:focus {
    background: #005a87;
    border-color: #005a87;
    transform: none;
    box-shadow: none;
}

.wp-admin .ttt-chrome-ai-btn::before {
    content: "🌐 ";
    margin-right: 5px;
}

/* Estilos para botones individuales en .wpml-form-row */
.wp-admin .wpml-translation-btn {
    background: #28a745;
    color: white;
    border: 1px solid #28a745;
    padding: 4px 8px !important;
    font-size: 12px !important;
    margin: 0 !important;
    min-height: auto !important;
    border-radius: 4px;
    text-decoration: none;
    box-shadow: none;
    transition: all 0.2s ease;
    position: absolute !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10 !important;
}

.wp-admin .wpml-translation-btn:hover,
.wp-admin .wpml-translation-btn:focus {
    background: #218838;
    border-color: #1e7e34;
    transform: translateY(-50%) scale(1.05) !important;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.wp-admin .wpml-translation-btn:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
    transform: translateY(-50%) !important;
    box-shadow: none;
}

/* Quitar iconos de planeta */
.wp-admin .wpml-translation-btn::before {
    content: none !important;
}

.wp-admin .wpml-translation-btn:disabled::before {
    content: none !important;
}

/* Contenedor del botón para posicionamiento absoluto */
.wp-admin .wpml-form-row {
    position: relative !important;
}

.wp-admin .wpml-form-row > div[style*="position: absolute"] {
    position: absolute !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 10 !important;
}

/* Modal */
.ttt-chrome-ai-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease;
}

.ttt-chrome-ai-modal[aria-hidden="true"] {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ttt-chrome-ai-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    animation: slideUp 0.3s ease;
    position: relative;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Modal Header */
.ttt-chrome-ai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e8eaed;
    background: #f8f9fa;
}

.ttt-chrome-ai-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #202124;
}

.ttt-chrome-ai-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #5f6368;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    min-height: 44px;
}

.ttt-chrome-ai-close:hover,
.ttt-chrome-ai-close:focus {
    background: #e8eaed;
    color: #202124;
    outline: 2px solid #4285f4;
    outline-offset: 2px;
}

/* Modal Body */
.ttt-chrome-ai-modal-body {
    padding: 24px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

/* Language Options */
.ttt-chrome-ai-languages h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #202124;
}

.ttt-chrome-ai-languages p {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #5f6368;
    border-left: 4px solid #4285f4;
}

.ttt-chrome-ai-language-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.ttt-chrome-ai-lang-btn {
    background: white;
    border: 2px solid #e8eaed;
    padding: 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 60px;
}

.ttt-chrome-ai-lang-btn:hover,
.ttt-chrome-ai-lang-btn:focus {
    border-color: #4285f4;
    background: #f8f9ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.15);
    outline: none;
}

.ttt-chrome-ai-lang-btn .lang-name {
    font-weight: 600;
    color: #202124;
    font-size: 14px;
}

.ttt-chrome-ai-lang-btn .lang-code {
    font-size: 12px;
    color: #5f6368;
    background: #e8eaed;
    padding: 2px 6px;
    border-radius: 4px;
    align-self: flex-start;
}

/* Progress Bar */
.ttt-chrome-ai-progress {
    margin: 20px 0;
}

.ttt-chrome-ai-progress-bar {
    background: #e8eaed;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.ttt-chrome-ai-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4285f4, #1a73e8);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.ttt-chrome-ai-progress-text {
    font-size: 14px;
    color: #5f6368;
    text-align: center;
    display: block;
}

/* Translation Result */
.ttt-chrome-ai-translation-result {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.ttt-chrome-ai-translation-result h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #202124;
}

.translation-text {
    background: white;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e8eaed;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
    color: #202124;
    max-height: 300px;
    overflow-y: auto;
}

.translation-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.copy-translation-btn,
.save-translation-btn {
    background: white;
    border: 2px solid #e8eaed;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    font-weight: 500;
}

.copy-translation-btn:hover,
.copy-translation-btn:focus,
.save-translation-btn:hover,
.save-translation-btn:focus {
    border-color: #4285f4;
    background: #f8f9ff;
    outline: 2px solid #4285f4;
    outline-offset: 2px;
}

.save-translation-btn {
    background: #4285f4;
    color: white;
    border-color: #4285f4;
}

.save-translation-btn:hover,
.save-translation-btn:focus {
    background: #1a73e8;
    border-color: #1a73e8;
}

/* Status Messages */
.ttt-chrome-ai-error,
.ttt-chrome-ai-info {
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-size: 14px;
    text-align: center;
}

.ttt-chrome-ai-error {
    background: #fef7f0;
    color: #d93025;
    border: 1px solid #f6aea9;
}

.ttt-chrome-ai-info {
    background: #e8f0fe;
    color: #1a73e8;
    border: 1px solid #b8d4f1;
}

/* Notifications */
.ttt-chrome-ai-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ttt-chrome-ai-notification.show {
    transform: translateX(0);
}

.ttt-chrome-ai-notification.ttt-chrome-ai-success {
    background: #e6f4ea;
    color: #137333;
    border: 1px solid #b7e1cd;
}

.ttt-chrome-ai-notification.ttt-chrome-ai-error {
    background: #fef7f0;
    color: #d93025;
    border: 1px solid #f6aea9;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ttt-chrome-ai-modal-content {
        width: 95%;
        margin: 20px;
        max-height: calc(100vh - 40px);
    }
    
    .ttt-chrome-ai-modal-header {
        padding: 16px 20px;
    }
    
    .ttt-chrome-ai-modal-body {
        padding: 20px;
    }
    
    .ttt-chrome-ai-language-list {
        grid-template-columns: 1fr;
    }
    
    .translation-actions {
        flex-direction: column;
    }
    
    .copy-translation-btn,
    .save-translation-btn {
        width: 100%;
    }
    
    .ttt-chrome-ai-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .ttt-chrome-ai-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .ttt-chrome-ai-modal-header h3 {
        font-size: 16px;
    }
    
    .ttt-chrome-ai-modal-body {
        padding: 16px;
    }
}

/* High Contrast Mode for Accessibility */
@media (prefers-contrast: high) {
    .ttt-chrome-ai-btn {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .ttt-chrome-ai-modal-content {
        border: 2px solid #000;
    }
    
    .ttt-chrome-ai-lang-btn {
        border: 2px solid #000;
    }
}

/* Reduced Motion for Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
