/**
 * AI Excel Assistant CSS Styles
 * 
 * @package AIFreeTools
 * @since 1.0.0
 */

/* Main Container */
.ai-excel-assistant-wrapper {
    max-width: 100%;
    margin: 0 auto;
}

.excel-tool-container {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Quick Action Buttons */
.excel-quick-actions {
    display: flex;
    gap: 15px;
    padding: 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e8ecef 100%);
    border-bottom: 2px solid #dee2e6;
    justify-content: center;
}

.excel-mode-btn {
    flex: 0 1 200px;
    padding: 15px 20px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    color: #333 !important;  /* Force default text color */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
}

/* Removed ::before overlay to prevent text visibility issues */

.excel-mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    border-color: #007cba;
    background: #f8f9fa;  /* Light background on hover */
}

.excel-mode-btn:hover .mode-icon,
.excel-mode-btn:hover .mode-text,
.excel-mode-btn:hover .mode-subtitle {
    color: #007cba !important;  /* Force hover state text color */
}

.excel-mode-btn.active {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: #fff;
    border-color: #007cba;
}

.excel-mode-btn.active .mode-icon,
.excel-mode-btn.active .mode-text,
.excel-mode-btn.active .mode-subtitle {
    color: #fff;
}

.mode-icon {
    font-size: 24px;
    position: relative;
    color: #555;
}

.mode-text {
    font-weight: 600;
    font-size: 15px;
    position: relative;
    color: #333;
}

.mode-subtitle {
    font-size: 11px;
    opacity: 0.9;
    position: relative;
    color: #666;
}

/* Non-active button styles */
.excel-mode-btn:not(.active) .mode-icon {
    color: #555;
}

.excel-mode-btn:not(.active) .mode-text {
    color: #333;
}

.excel-mode-btn:not(.active) .mode-subtitle {
    color: #666;
}

/* Upload Section - Reduced Size */
.excel-upload-section {
    padding: 15px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}

.upload-container {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.upload-container.uploading {
    opacity: 0.6;
    pointer-events: none;
}

.upload-prompt {
    text-align: center;
    padding: 20px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 20px;
}

.upload-icon {
    font-size: 36px;
    display: block;
    flex-shrink: 0;
}

.upload-content {
    flex: 1;
    text-align: left;
}

.upload-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 3px;
    color: #2c3e50;
}

.upload-subtitle {
    font-size: 13px;
    color: #666;
    margin: 0;
}

.btn-upload {
    background: #007cba;
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.3s ease;
    margin-left: auto;
    flex-shrink: 0;
}

.btn-upload:hover {
    background: #005a87;
}

.upload-note {
    font-size: 11px;
    color: #999;
    margin: 8px 0 0;
    display: none; /* Hide to save space */
}

/* File Info Display - Compact */
.file-info {
    background: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 6px;
    padding: 10px 15px;
}

.file-details {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    font-size: 24px;
}

.file-meta {
    flex: 1;
}

.file-name {
    font-weight: 600;
    margin: 0;
    color: #2c3e50;
    font-size: 14px;
}

.file-stats {
    font-size: 12px;
    color: #666;
    margin: 2px 0 0;
}

.btn-remove-file {
    background: #dc3545;
    color: #fff;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.btn-remove-file:hover {
    background: #c82333;
}

/* Input Section - Increased Size */
.excel-input-section {
    padding: 25px 20px;
}

.input-container {
    max-width: 100%;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.input-label {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.btn-clear {
    background: transparent;
    border: 1px solid #ddd;
    padding: 5px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.3s ease;
}

.btn-clear:hover {
    background: #f0f0f0;
    border-color: #999;
}

.excel-textarea {
    width: 100%;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
    min-height: 120px; /* Increased minimum height */
    line-height: 1.5;
}

.excel-textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
    background: #fafafa;
}

.excel-textarea.formula-inserted {
    animation: highlightInsert 0.5s ease;
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.3);
}

@keyframes highlightInsert {
    0% {
        background: rgba(40, 167, 69, 0.1);
        transform: scale(1);
    }
    50% {
        background: rgba(40, 167, 69, 0.2);
        transform: scale(1.01);
    }
    100% {
        background: #fff;
        transform: scale(1);
    }
}

/* Context Helper */
.context-helper {
    margin-top: 15px;
    padding: 12px;
    background: #f0f8ff;
    border: 1px solid #b3d9ff;
    border-radius: 6px;
}

.context-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.context-icon {
    font-size: 18px;
}

.context-title {
    font-weight: 600;
    color: #0066cc;
}

.sheet-info {
    margin-bottom: 8px;
    font-size: 14px;
}

.column-tag {
    display: inline-block;
    background: #e7f3ff;
    padding: 2px 8px;
    border-radius: 3px;
    margin: 2px;
    font-size: 12px;
    color: #0066cc;
}

.more-columns {
    color: #666;
    font-style: italic;
}

/* Input Footer */
.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.char-counter {
    font-size: 13px;
    color: #999;
    font-weight: 500;
}

.char-counter.over-limit {
    color: #dc3545;
}

.btn-primary {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: #fff;
    border: none;
    padding: 14px 35px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 124, 186, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #005a87 0%, #004a6f 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 124, 186, 0.3);
}

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

/* Loading State */
.excel-loading {
    padding: 40px;
    text-align: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-text {
    color: #666;
    font-size: 14px;
}

/* Output Section */
.excel-output-section {
    border-top: 1px solid #e0e0e0;
    background: #fafafa;
}

.output-container {
    padding: 20px;
}

/* Formula Result */
.formula-result {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

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

.formula-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.btn-copy {
    background: #28a745;
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    transition: background 0.3s ease;
}

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

.formula-box {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
    position: relative;
}

.excel-formula {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 16px;
    color: #0066cc;
    display: block;
    word-break: break-all;
}

.copy-feedback {
    background: #28a745;
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    margin-top: 10px;
    font-size: 14px;
    text-align: center;
}

/* Explanation Section */
.formula-explanation,
.formula-alternatives {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

.explanation-title,
.alternatives-title {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 15px;
}

.explanation-content,
.alternatives-content {
    font-size: 14px;
    line-height: 1.6;
    color: #333;
}

.explanation-content p {
    margin: 0 0 10px;
}

.explanation-content ul,
.alternatives-content ul {
    margin: 10px 0;
    padding-left: 25px;
}

.alternatives-content code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    color: #0066cc;
}

/* Output Footer */
.output-footer {
    text-align: center;
    padding-top: 20px;
}

.btn-try-another {
    background: #6c757d;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.btn-try-another:hover {
    background: #5a6268;
}

/* Templates Section */
.excel-templates-section {
    padding: 30px 20px;
    border-top: 2px solid #e0e0e0;
    background: linear-gradient(180deg, #fafafa 0%, #fff 100%);
}

.templates-header {
    text-align: center;
    margin-bottom: 25px;
}

.templates-title {
    font-size: 22px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.title-icon {
    font-size: 26px;
}

.templates-subtitle {
    font-size: 14px;
    color: #666;
    margin: 0 0 20px;
}

.template-categories {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.category-btn {
    background: #fff;
    border: 2px solid #e0e0e0;
    padding: 8px 16px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #333;  /* Added text color for default state */
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.cat-icon {
    font-size: 16px;
}

.category-btn:hover {
    background: #f8f9fa;
    border-color: #007cba;
    color: #007cba;  /* Added hover text color */
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
}

.category-btn.active {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: #fff !important;  /* Keep white text for active state with !important */
    border-color: #007cba;
    box-shadow: 0 3px 10px rgba(0,124,186,0.3);
}

.category-btn.active .cat-icon {
    filter: brightness(0) invert(1);  /* Make emoji icons white in active state */
}

.templates-carousel {
    position: relative;
    padding: 0 50px;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: #007cba;
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 10;
}

.carousel-prev {
    left: 0;
}

.carousel-next {
    right: 0;
}

.carousel-nav:hover {
    background: #005a87;
    transform: translateY(-50%) scale(1.1);
}

.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.template-card {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: visible;  /* Changed from hidden to visible */
}

.template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    border-color: #007cba;
    background: #f8f9fa;  /* Light background on hover */
    z-index: 10;  /* Ensure it's above other cards */
}

.template-header {
    margin-bottom: 10px;
}

.template-category {
    display: inline-block;
    background: #e7f3ff;
    color: #0066cc;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 5px;
}

.template-name {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

/* Ensure text remains visible on hover */
.template-card:hover .template-name {
    color: #007cba;  /* Change to primary color on hover */
}

.template-card:hover .template-category {
    background: #007cba;
    color: #fff;
}

.template-card:hover .template-description {
    color: #495057;  /* Ensure description stays readable */
}

.template-card:hover .template-formula {
    background: #fff;  /* White background for formula */
    border: 1px solid #007cba;
}

.template-body {
    margin-bottom: 10px;
}

.template-formula {
    display: block;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #0066cc;
    margin: 10px 0;
    word-break: break-all;
}

.template-description {
    font-size: 13px;
    color: #666;
    margin: 8px 0;
}

.btn-use-template {
    background: #007cba;
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    width: 100%;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.btn-use-template:hover {
    background: #005a87;
    color: #fff !important;  /* Ensure text stays white */
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Ensure button text always visible in template card */
.template-card .btn-use-template {
    color: #fff !important;
}

/* History Section */
.excel-history-section {
    margin: 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
}

.history-header {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
}

.history-header:hover {
    background: #e9ecef;
}

.history-icon {
    font-size: 18px;
}

.history-count {
    color: #666;
    font-weight: normal;
}

.history-content {
    padding: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.history-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    margin: 20px 0;
}

.history-item {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

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

.history-meta {
    margin-bottom: 8px;
}

.history-timestamp {
    font-size: 12px;
    color: #999;
}

.history-input {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.history-formula {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 8px;
    border-radius: 4px;
}

.history-formula code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #0066cc;
}

.btn-copy-history {
    background: #28a745;
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.3s ease;
}

.btn-copy-history:hover {
    background: #218838;
}

/* Notifications */
.excel-notification {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: 6px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.excel-notification.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.excel-notification.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.excel-notification.info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.excel-notification.warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.notification-icon {
    font-size: 18px;
}

.notification-message {
    flex: 1;
}

.notification-close {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.notification-close:hover {
    opacity: 1;
}

/* CAPTCHA Styles */
.excel-captcha-container {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .excel-quick-actions {
        flex-direction: column;
    }
    
    .excel-mode-btn {
        width: 100%;
    }
    
    .templates-grid {
        grid-template-columns: 1fr;
    }
    
    .formula-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .input-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .btn-primary {
        width: 100%;
    }
}

/* Print Styles */
@media print {
    .excel-quick-actions,
    .excel-upload-section,
    .btn-copy,
    .btn-try-another,
    .excel-templates-section,
    .excel-history-section {
        display: none !important;
    }
    
    .excel-tool-container {
        box-shadow: none;
        border: 1px solid #000;
    }
}