/* AI Text Humanizer - Modern UI/UX Design */

/* Container and Main Interface */
.aifreetools-text-humanizer-container {    
    padding-top: 0px;
}

.main-interface {
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

/* Editor Layout */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 600px;
}

.input-panel, .output-panel {
    display: flex;
    flex-direction: column;
}

.input-panel {
    border-right: 1px solid #e2e8f0;
}

/* Panel Headers */
.panel-header {
    padding: 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
}

.char-count, .word-count {
    font-size: 0.875rem;
    color: #64748b;
}

.char-count.near-limit, .word-count.near-limit {
    color: #dc2626;
}

/* Panel Content */
.panel-content {
    flex: 1;
    padding: 0;
    position: relative;
    display: flex;
    flex-direction: column;
}

.textarea-container {
    position: relative;
    height: 100%;
}

.input-textarea {
    width: 100%;
    height: 100%;
    border: none;
    padding: 20px;
    padding-top: 60px;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: box-shadow 0.2s ease;
}

/* Prevent any browser default focus styles */
.input-textarea::-webkit-outer-spin-button,
.input-textarea::-webkit-inner-spin-button {
    -webkit-appearance: none;
}

.input-textarea:-webkit-autofill,
.input-textarea:-webkit-autofill:hover,
.input-textarea:-webkit-autofill:focus {
    -webkit-box-shadow: none;
    box-shadow: none;
}

/* Textarea Actions */
.textarea-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.textarea-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.textarea-btn:hover {
    background: white;
    border-color: #cbd5e1;
    color: #475569;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.textarea-btn span {
    font-size: 0.875rem;
}

/* Output Content */
.output-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
    background: #fafbfc;
}

.output-placeholder {
    color: #94a3b8;
    font-style: italic;
    text-align: center;
    margin-top: 50px;
    display: block;
    padding: 20px;
    font-size: 0.95rem;
}

.output-text {
    font-size: 14px;
    line-height: 1.6;
    color: #334155;
    white-space: pre-wrap;
    /* Override conflicting theme styles */
    background: transparent !important;
    border: none !important;
    height: auto !important;
    padding: 0 !important;
    position: static !important;
    overflow-y: visible !important;
}

/* Panel Actions */
.panel-actions {
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 88px;
    box-sizing: border-box;
}

.input-panel .panel-actions {
    justify-content: space-between;
}

.output-panel .panel-actions {
    justify-content: flex-end;
}

.input-actions, .output-actions {
    display: flex;
    gap: 12px;
}

/* Direct CAPTCHA styling without containers */
.g-recaptcha,
.cf-turnstile {
    display: inline-block;
}

/* reCAPTCHA Specific Styling */
.panel-actions .g-recaptcha {
    transform: scale(0.9);
    transform-origin: 0 0;
}

/* Turnstile Specific Styling */
.panel-actions .cf-turnstile {
    transform: scale(0.9);
    transform-origin: 0 0;
}

/* Controls Bar */
.controls-bar {
    background: linear-gradient(135deg, #1e40af 0%, #0f766e 100%);
    padding: 20px;
    color: white;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.control-group {
    display: flex;
    flex-direction: column;
}

.control-group label {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.9);
}

.control-group select {
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    color: #334155;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.control-group select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* Advanced Options */
.advanced-toggle {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.advanced-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.advanced-options {
    margin-top: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 20px;
    display: none;
}

.advanced-options.open {
    display: block;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

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

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.checkbox-item label {
    font-size: 0.875rem;
    margin: 0;
    color: rgba(255, 255, 255, 0.9);
}

.custom-instructions {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    resize: vertical;
    min-height: 80px;
}

.custom-instructions::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #1e40af 0%, #0f766e 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 15px rgba(30, 64, 175, 0.3);
}

.btn-secondary {
    background: white;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #f8fafc;
}

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

/* Loading Overlay */
.loading-overlay,
.aifreetools-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 100;
    /* Start hidden */
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* Active state - show the overlay */
.loading-overlay.active,
.aifreetools-loading-overlay.active {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Ensure hiding when not active */
.loading-overlay:not(.active),
.aifreetools-loading-overlay:not(.active) {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #1e40af;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Stats Bar */
.stats-bar {
    padding: 16px 20px;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 16px;
    font-size: 0.875rem;
    margin: 0;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-weight: 700;
    color: #1e293b;
    display: block;
}

.stat-label {
    color: #64748b;
    font-size: 0.75rem;
}

/* Messages */
.error-message, .success-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 20px;
    display: none;
}

.error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.success-message {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

/* Tool Footer */
.tool-footer {
    margin-top: 40px;
}

.how-it-works {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.how-it-works h3 {
    margin: 0 0 25px 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 10px;
}

.how-it-works-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
}

.feature-explanation {
    background: #f8fafc;
    border-radius: 12px;
    padding: 24px;
    border: 1px solid #e2e8f0;
}

.feature-explanation h4 {
    margin: 0 0 16px 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.feature-explanation p {
    margin: 0 0 12px 0;
    font-size: 0.875rem;
    color: #64748b;
    line-height: 1.6;
}

.feature-explanation ul {
    margin: 12px 0 0 0;
    padding-left: 20px;
}

.feature-explanation li {
    margin-bottom: 8px;
    font-size: 0.875rem;
    color: #475569;
    line-height: 1.5;
}

.feature-explanation li strong {
    color: #1e293b;
    font-weight: 600;
}

/* Diff Examples */
.diff-example {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.875rem;
}

.diff-example.removed {
    background-color: #fef2f2;
    color: #dc2626;
    text-decoration: line-through;
}

.diff-example.added {
    background-color: #f0fdf4;
    color: #166534;
    font-weight: 500;
}

/* Style Guidelines Box */
.style-guidelines-box .guidelines-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.style-guidelines-box .tips-section,
.style-guidelines-box .avoid-section {
    background: white;
    border-radius: 8px;
    padding: 16px;
    border: 1px solid #e2e8f0;
}

.style-guidelines-box .tips-section {
    border-left: 4px solid #10b981;
}

.style-guidelines-box .avoid-section {
    border-left: 4px solid #ef4444;
}

.style-guidelines-box .tips-section h5,
.style-guidelines-box .avoid-section h5 {
    margin: 0 0 10px 0;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.style-guidelines-box .tips-section h5 {
    color: #065f46;
}

.style-guidelines-box .avoid-section h5 {
    color: #b91c1c;
}

.style-guidelines-box .tips-section ul,
.style-guidelines-box .avoid-section ul {
    margin: 0;
    padding-left: 16px;
}

.style-guidelines-box .tips-section li,
.style-guidelines-box .avoid-section li {
    margin-bottom: 6px;
    font-size: 0.8rem;
    color: #475569;
    line-height: 1.4;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .editor-layout {
        grid-template-columns: 1fr;
    }

    .input-panel {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .editor-layout {
        min-height: auto;
    }

    .panel-content {
        min-height: 300px;
    }

    .how-it-works-content {
        grid-template-columns: 1fr;
    }
    
    .style-guidelines-box .guidelines-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .aifreetools-text-humanizer-container {
        padding: 12px;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }

    .panel-actions {
        flex-direction: column;
        align-items: stretch;
        height: auto;
        gap: 12px;
    }

    /* Direct CAPTCHA responsive styles */
    .panel-actions .g-recaptcha,
    .panel-actions .cf-turnstile {
        transform: scale(0.8);
        margin: 0 auto;
    }

    .input-actions, .output-actions {
        flex-direction: column;
        width: 100%;
    }

    /* CAPTCHA scales down on mobile */
    .g-recaptcha,
    .cf-turnstile {
        max-width: 100%;
    }

    .textarea-actions {
        top: 8px;
        right: 8px;
        flex-direction: column;
        gap: 6px;
    }

    .textarea-btn {
        padding: 8px 10px;
        font-size: 0.7rem;
    }

    .input-textarea {
        padding-top: 80px;
    }

    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }

    .tool-footer {
        margin-top: 20px;
    }

    .how-it-works {
        padding: 20px;
        margin-bottom: 20px;
    }

    .how-it-works-content {
        gap: 20px;
    }

    .feature-explanation {
        padding: 20px;
    }

    .style-guidelines-box .guidelines-content {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .style-guidelines-box .tips-section,
    .style-guidelines-box .avoid-section {
        padding: 12px;
    }
}

/* Hidden elements for backward compatibility */
.humanizer-form {
    margin: 0;
}

.toggle-advanced .toggle-icon {
    display: none !important;
}

.loading-spinner {
    margin-left: 5px;
}

/* Additional compatibility styles - kept for JS compatibility but no styles needed */

/* Pattern table for analysis */
.pattern-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.pattern-table th,
.pattern-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.pattern-table th {
    font-weight: 600;
    background: #f8fafc;
    color: #1e293b;
}

.pattern-table td {
    color: #475569;
}

/* Diff highlighting for comparison */
.diff-original {
    background-color: #fef2f2;
    color: #dc2626;
    text-decoration: line-through;
    padding: 2px 4px;
    border-radius: 3px;
}

.diff-humanized {
    background-color: #f0fdf4;
    color: #166534;
    font-weight: 500;
    padding: 2px 4px;
    border-radius: 3px;
}

/* Advanced content animations */
.advanced-content {
    transition: all 0.3s ease-in-out;
}

/* Focus states for accessibility */
.input-textarea:focus,
.control-group select:focus,
.custom-instructions:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(30, 64, 175, 0.2);
}

/* Remove default focus outline */
.input-textarea:focus-visible {
    outline: none;
}

/* Loading animation improvements */
.aifreetools-spinner-container {
    text-align: center;
}

.aifreetools-spinner-container p {
    margin-top: 16px;
    color: #64748b;
    font-size: 0.875rem;
}

/* Legacy support */
.aifreetools-input-container {
    position: relative;
    height: 100%;
}

/* Combined loading overlay styles - merged with main loading overlay styles above */

.aifreetools-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #1e40af;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* Form and section compatibility - preserved for backward compatibility */

/* Output panel visibility */
.output-panel {
    display: flex;
}

#humanizer-results {
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* Make sure hidden elements stay hidden */
#humanized-text,
#original-text,
#comparison-original,
#comparison-humanized,
#analysis-section,
#similarity-metric,
#humanization-score,
.results-tabs,
.tab-content,
.humanize-again-button {
    display: none !important;
}

/* Output content dynamic update */
#output-content:has(.output-text) .output-placeholder {
    display: none;
}

/* Ensure output text is properly displayed */
.output-text {
    display: block;
    width: 100%;
}

/* Hide placeholder when output text exists */
#output-content .output-text + .output-placeholder,
#output-content .output-placeholder:not(:only-child) {
    display: none;
}

/* Reset button styling */
.reset-button {
    display: none;
}