/**
 * Deep Humanizer - Modern UI Design
 * Updated with new writing animation and output box processing
 */

/* CSS Custom Properties */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-dark: #1e40af;
    --accent-color: #06b6d4;
    --accent-hover: #0891b2;
    --success-color: #059669;
    --success-light: #a7f3d0;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --warning-border: #f59e0b;
    --warning-text: #b45309;
    --warning-title: #92400e;
    --error-color: #dc2626;
    --error-light: #fecaca;
    --light-bg: #ffffff;
    --light-bg-secondary: #f9fafb;
    --light-bg-tertiary: #f3f4f6;
    --light-border: #e5e7eb;
    --light-border-secondary: #d1d5db;
    --dark-text: #1f2937;
    --dark-text-secondary: #374151;
    --light-text: #6b7280;
    --light-text-secondary: #9ca3af;
    --blue-400: #60a5fa;
    --blue-300: #93c5fd;
    --blue-text: #1d4ed8;
    --green-400: #34d399;
    --green-500: #10b981;
    --green-600: #059669;
    --green-light: #d1fae5;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
    --spacing-xl: 1.5rem;
    --spacing-2xl: 2rem;
    --spacing-3xl: 3rem;
    --radius: 0.75rem;
    --radius-sm: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --transition-fast: 0.15s ease-out;
    --transition-base: 0.2s ease-out;
    --transition-slow: 0.3s ease-out;
}

/* Reset and basic styles */
.deep-humanizer-container * {
    box-sizing: border-box;
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
}

.deep-humanizer-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-xl);
    line-height: 1.6;
    color: var(--dark-text);
    background-color: transparent;
    position: relative;
}

/* Text Boxes Container - Side by Side */
.deep-humanizer-text-boxes-container {
    display: flex;
    gap: var(--spacing-xl);
    margin-bottom: var(--spacing-2xl);
}

.deep-humanizer-text-box-wrapper {
    flex: 1;
    min-width: 0;
}

.deep-humanizer-box-header {
    display: flex;
    align-items: center;
    font-weight: 500;
    color: var(--dark-text);
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-base);
}

.deep-humanizer-document-sparkle-icon {
    position: relative;
    margin-left: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.deep-humanizer-file-icon {
    color: var(--blue-400);
}

.deep-humanizer-sparkle-icon {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    color: var(--blue-300);
}

.deep-humanizer-text-box {
    position: relative;
    height: 24rem;
    overflow: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--light-border);
    background-color: var(--light-bg);
    box-shadow: var(--shadow-sm);
}

.deep-humanizer-text-area {
    height: calc(100% - 3rem);
    width: 100%;
    resize: none;
    border: 0;
    padding: var(--spacing-lg);
    font-size: var(--font-size-sm);
    color: var(--dark-text-secondary);
    outline: none;
    background: transparent;
    font-weight: 400;
    line-height: 1.6;
}

.deep-humanizer-text-area:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

.deep-humanizer-empty-state {
    display: flex;
    height: calc(100% - 3rem);
    width: 100%;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--light-text);
}

.deep-humanizer-paste-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-xl);
    border-radius: var(--radius);
    transition: all var(--transition-base);
    cursor: pointer;
}

.deep-humanizer-paste-button:hover {
    background-color: var(--light-bg-secondary);
    transform: scale(1.05);
}

.deep-humanizer-paste-icon {
    color: var(--light-text-secondary);
}

.deep-humanizer-paste-button span {
    font-size: var(--font-size-base);
    font-weight: 500;
}

.deep-humanizer-animated-icon-container {
    margin-bottom: var(--spacing-md);
}

/* Updated Animation - Green Document Icon Only, No Glow */
.deep-humanizer-document-animated-icon {
    animation: float 3s ease-in-out infinite;
}

.deep-humanizer-animated-file-icon {
    color: var(--green-500);
}

@keyframes float {
    0%, 100% { 
        transform: translateY(-3px);
    }
    50% { 
        transform: translateY(3px);
    }
}

.deep-humanizer-word-count {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    border-top: 1px solid var(--light-border);
    background-color: var(--light-bg-secondary);
    padding: var(--spacing-sm) var(--spacing-lg);
    text-align: right;
    font-size: var(--font-size-xs);
    color: var(--light-text);
}

/* Processing overlay - Now positioned in output box with new writing animation */
.deep-humanizer-processing {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.deep-humanizer-processing-content {
    text-align: center;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    padding: var(--spacing-2xl);
}

/* New Writing Animation */
.deep-humanizer-writing-animation-container {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-md);
}

.deep-humanizer-writing-animation {
    filter: drop-shadow(0 4px 8px rgba(16, 185, 129, 0.2));
}

/* Writing Lines Animation */
@keyframes writeText {
    0% { 
        stroke-dasharray: 0 100;
        opacity: 0.3;
    }
    50% {
        stroke-dasharray: 50 100;
        opacity: 1;
    }
    100% { 
        stroke-dasharray: 100 100;
        opacity: 0.8;
    }
}

.writing-line {
    stroke-dasharray: 0 100;
    animation: writeText 2s ease-in-out infinite;
}

.writing-line.line-1 { animation-delay: 0s; }
.writing-line.line-2 { animation-delay: 0.4s; }
.writing-line.line-3 { animation-delay: 0.8s; }
.writing-line.line-4 { animation-delay: 1.2s; }
.writing-line.line-5 { animation-delay: 1.6s; }

/* Animated Pen */
@keyframes penMove {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(5px, 15px) rotate(10deg); }
    50% { transform: translate(0, 30px) rotate(0deg); }
    75% { transform: translate(-3px, 45px) rotate(-5deg); }
    100% { transform: translate(0, 60px) rotate(0deg); }
}

.animated-pen {
    animation: penMove 2s ease-in-out infinite;
    transform-origin: center;
}

.deep-humanizer-processing-status {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0;
    color: var(--dark-text);
    line-height: 1.4;
}

.deep-humanizer-progress-container {
    width: 100%;
    background-color: #e5e7eb;
    border-radius: 9999px;
    height: 10px;
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.deep-humanizer-progress-bar {
    background: linear-gradient(90deg, #10b981 0%, #059669 50%, #047857 100%);
    height: 100%;
    width: 0%;
    border-radius: 9999px;
    transition: width var(--transition-slow);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
    position: relative;
}

.deep-humanizer-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.deep-humanizer-time-remaining {
    font-size: var(--font-size-sm);
    color: var(--light-text);
    font-weight: 500;
    background: rgba(16, 185, 129, 0.1);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Action buttons */
.deep-humanizer-buttons {
    position: absolute;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    display: flex;
    gap: var(--spacing-sm);
    z-index: 5;
}

.deep-humanizer-button {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    min-height: 36px;
}

.deep-humanizer-button-secondary {
    background: var(--light-bg);
    color: var(--dark-text-secondary);
    border: 1px solid var(--light-border-secondary);
}

.deep-humanizer-button-secondary:hover {
    background: var(--light-bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.deep-humanizer-button-icon {
    height: 16px;
    width: 16px;
    margin-right: var(--spacing-xs);
    flex-shrink: 0;
}

/* Dropdown */
.deep-humanizer-dropdown {
    position: relative;
    display: inline-block;
}

.deep-humanizer-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--light-bg);
    min-width: 200px;
    box-shadow: var(--shadow-xl);
    z-index: 20;
    border-radius: var(--radius-sm);
    margin-top: var(--spacing-xs);
    border: 1px solid var(--light-border);
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.deep-humanizer-dropdown:hover .deep-humanizer-dropdown-content,
.deep-humanizer-dropdown:focus-within .deep-humanizer-dropdown-content {
    display: block;
    animation: fadeInUp 0.2s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.deep-humanizer-dropdown-item {
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.deep-humanizer-dropdown-item:hover {
    background: var(--light-bg-secondary);
    color: var(--primary-color);
}

.deep-humanizer-dropdown-icon {
    height: 18px;
    width: 18px;
    margin-right: var(--spacing-md);
    flex-shrink: 0;
}

/* Freeze Keywords Section */
.deep-humanizer-freeze-section {
    background-color: var(--light-bg-secondary);
    border-radius: var(--radius);
    padding: var(--spacing-xl);
    border: 1px solid var(--light-border);
    margin-bottom: var(--spacing-2xl);
}

.deep-humanizer-freeze-header {
    margin-bottom: var(--spacing-lg);
}

.deep-humanizer-section-title {
    display: flex;
    align-items: center;
    font-weight: 500;
    color: var(--dark-text);
    font-size: var(--font-size-base);
    margin-bottom: var(--spacing-lg);
}

.deep-humanizer-info-icon {
    margin-left: var(--spacing-sm);
    color: var(--light-text-secondary);
}

.deep-humanizer-freeze-description {
    font-size: var(--font-size-sm);
    color: var(--dark-text-secondary);
    margin-bottom: var(--spacing-lg);
    line-height: 1.5;
}

.deep-humanizer-warning-box {
    background-color: var(--warning-light);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-sm);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
    line-height: 1.5;
}

.deep-humanizer-warning-icon {
    color: var(--warning-color);
    flex-shrink: 0;
}

.deep-humanizer-warning-content {
    flex: 1;
}

.deep-humanizer-warning-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--warning-title);
    margin-bottom: var(--spacing-xs);
}

.deep-humanizer-warning-text {
    font-size: var(--font-size-sm);
    color: var(--warning-text);
    margin: 0;
}

.deep-humanizer-keyword-placeholder {
    background-color: #dbeafe;
    border-radius: var(--radius-sm);
    padding: var(--spacing-lg);
    text-align: center;
    font-size: var(--font-size-sm);
    color: var(--blue-text);
    margin-bottom: var(--spacing-lg);
    min-height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.deep-humanizer-keyword-pill {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 9999px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    transition: all var(--transition-base);
    cursor: default;
    max-width: 100%;
    word-break: break-word;
}

.deep-humanizer-keyword-pill:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.deep-humanizer-keyword-remove {
    margin-left: var(--spacing-sm);
    font-weight: 700;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-size: var(--font-size-sm);
    line-height: 1;
    color: currentColor;
    transition: all var(--transition-fast);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.deep-humanizer-keyword-remove:hover {
    color: var(--error-color);
    background-color: rgba(220, 38, 38, 0.1);
}

.deep-humanizer-keyword-input-container {
    display: flex;
    gap: var(--spacing-sm);
}

.deep-humanizer-keyword-input {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--light-border-secondary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    outline: none;
    transition: all var(--transition-base);
}

.deep-humanizer-keyword-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.deep-humanizer-add-button {
    padding: var(--spacing-sm) var(--spacing-lg);
    background-color: var(--light-border);
    color: var(--dark-text-secondary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    border: none;
    cursor: pointer;
    transition: background-color var(--transition-base);
    font-weight: 500;
}

.deep-humanizer-add-button:hover {
    background-color: var(--light-border-secondary);
}

/* Inline Turnstile Container (Above Button) */
.deep-humanizer-inline-turnstile-container {
    display: flex;
    justify-content: center;
    margin-bottom: var(--spacing-xl);
    animation: slideInDown 0.3s ease-out;
}

.deep-humanizer-turnstile-widget {
    display: inline-block;
    transition: all var(--transition-base);
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Turnstile Error Styles */
.deep-humanizer-turnstile-error {
    display: none;
    margin-top: var(--spacing-lg);
    padding: var(--spacing-md);
    background: linear-gradient(135deg, var(--error-light) 0%, rgba(254, 202, 202, 0.3) 100%);
    border: 1px solid var(--error-color);
    border-radius: var(--radius-sm);
    animation: slideInDown 0.3s ease-out;
    text-align: center;
}

.deep-humanizer-turnstile-error-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    color: var(--error-color);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.deep-humanizer-turnstile-error-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* API Status Warning */
.deep-humanizer-api-warning {
    display: none;
    align-items: flex-start;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
    padding: var(--spacing-lg);
    background: linear-gradient(135deg, var(--error-light) 0%, rgba(254, 202, 202, 0.3) 100%);
    border: 1px solid var(--error-color);
    border-radius: var(--radius-sm);
    color: var(--error-color);
    font-weight: 500;
    font-size: var(--font-size-sm);
}

.deep-humanizer-api-warning .deep-humanizer-warning-icon {
    color: var(--error-color);
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 2px;
}

/* Humanize Button - Centered */
.deep-humanizer-action {
    display: flex;
    justify-content: center;
}

.deep-humanizer-humanize-button {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--spacing-md);
    width: 100%;
    max-width: 24rem;
    padding: var(--spacing-lg) var(--spacing-2xl);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    background: linear-gradient(to right, var(--primary-color), var(--primary-hover));
}

.deep-humanizer-humanize-button:enabled:hover {
    background: linear-gradient(to right, var(--primary-hover), var(--primary-dark));
    transform: scale(1.05);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.deep-humanizer-humanize-button:disabled {
    background: linear-gradient(to right, var(--light-text-secondary), var(--light-border-secondary));
    cursor: not-allowed;
    opacity: 0.7;
    transform: none;
}

.deep-humanizer-humanize-button:disabled span {
    font-size: var(--font-size-sm);
}

/* Loading state for main button */
.deep-humanizer-button-loading {
    position: relative;
    pointer-events: none;
}

.deep-humanizer-button-loading .deep-humanizer-document-sparkle-icon {
    opacity: 0;
}

.deep-humanizer-button-loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    left: 50%;
    top: 50%;
    margin-left: -9px;
    margin-top: -9px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .deep-humanizer-text-boxes-container {
        flex-direction: column;
    }
    
    .deep-humanizer-container {
        padding: var(--spacing-lg);
    }
    
    .deep-humanizer-text-box {
        height: 20rem;
    }
    
    .deep-humanizer-buttons {
        position: static;
        margin-top: var(--spacing-lg);
        justify-content: center;
    }
    
    .deep-humanizer-text-area {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .deep-humanizer-inline-turnstile-container {
        margin-bottom: var(--spacing-lg);
    }
}

/* Notification System */
.deep-humanizer-notification {
    position: fixed;
    top: var(--spacing-xl);
    right: var(--spacing-xl);
    left: var(--spacing-xl);
    max-width: 400px;
    margin-left: auto;
    z-index: 1000;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-xl);
    animation: slideInRight 0.3s ease-out;
}

@media (min-width: 768px) {
    .deep-humanizer-notification {
        left: auto;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.deep-humanizer-notification-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
}

.deep-humanizer-notification-success .deep-humanizer-notification-content {
    background: linear-gradient(135deg, var(--success-light) 0%, rgba(167, 243, 208, 0.7) 100%);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.deep-humanizer-notification-warning .deep-humanizer-notification-content {
    background: linear-gradient(135deg, var(--warning-light) 0%, rgba(254, 215, 170, 0.7) 100%);
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
}

.deep-humanizer-notification-error .deep-humanizer-notification-content {
    background: linear-gradient(135deg, var(--error-light) 0%, rgba(254, 202, 202, 0.7) 100%);
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

.deep-humanizer-notification-info .deep-humanizer-notification-content {
    background: linear-gradient(135deg, #dbeafe 0%, rgba(219, 234, 254, 0.7) 100%);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.deep-humanizer-notification-close {
    background: none;
    border: none;
    font-size: var(--font-size-lg);
    cursor: pointer;
    color: currentColor;
    padding: var(--spacing-xs);
    margin-left: var(--spacing-sm);
    opacity: 0.7;
    transition: opacity var(--transition-fast);
    flex-shrink: 0;
    min-width: 24px;
    min-height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.deep-humanizer-notification-close:hover {
    opacity: 1;
}

/* Focus styles for accessibility */
.deep-humanizer-button:focus,
.deep-humanizer-keyword-input:focus,
.deep-humanizer-text-area:focus,
.deep-humanizer-add-button:focus,
.deep-humanizer-humanize-button:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Touch-friendly improvements */
@media (max-width: 767px) {
    .deep-humanizer-button,
    .deep-humanizer-add-button,
    .deep-humanizer-keyword-remove {
        min-height: 44px;
        min-width: 44px;
    }
    
    .deep-humanizer-keyword-input {
        min-height: 44px;
    }
}