/**
 * Main Stylesheet for AI Text Humanizer Platform
 * Theme: Soft Professional - Light mode with warm neutrals and softer purple
 */

/* ============================================================================
   CSS VARIABLES (COLOR SCHEME)
   ============================================================================ */
:root {
    /* === BACKGROUND COLORS (Softer, warmer - reduced eye strain) === */
    --color-bg-primary: #FAF7F2;        /* Warm cream (main background) */
    --color-bg-secondary: #F5F1EB;      /* Warm beige (cards, sections) */
    --color-bg-tertiary: #E8E4DE;       /* Warm gray borders/dividers */
    --color-white: #FBF8F3;             /* Soft white (not harsh pure white) */

    /* Legacy naming for compatibility */
    --color-dark: #FAF7F2;              /* Now light cream (body background) */
    --color-slate: #F5F1EB;             /* Now warm beige (cards) */

    /* === TEXT COLORS === */
    --color-text-primary: #1C1917;      /* Rich black (headings, main text) */
    --color-text-secondary: #57534E;    /* Medium gray (body text) */
    --color-text-tertiary: #78716C;     /* Light gray (muted text) */
    --color-text-muted: #A8A29E;        /* Very light gray (placeholders) */

    /* === BRAND COLORS (Softer Purple) === */
    --color-purple: #8B5CF6;            /* Softer violet (was harsh #7C3AED) */
    --color-purple-hover: #7C3AED;      /* Original purple only on hover */
    --color-purple-light: #EDE9FE;      /* Very light purple for backgrounds */

    /* === ACCENT COLORS === */
    --color-blue: #14B8A6;              /* Teal (subtle nature connection) */
    --color-blue-light: #CCFBF1;        /* Light teal for backgrounds */

    /* === PRIMARY/ACCENT ALIASES === */
    --color-primary: #8B5CF6;           /* Main brand color */
    --color-primary-hover: #7C3AED;     /* Hover state */
    --color-primary-light: #EDE9FE;     /* Light backgrounds */
    --color-accent: #14B8A6;            /* Teal accent */
    --color-accent-light: #CCFBF1;      /* Light teal */

    /* === STATUS COLORS === */
    --color-success: #10B981;
    --color-warning: #F59E0B;
    --color-error: #EF4444;
    --color-info: #3B82F6;

    /* === SPACING === */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* === BORDER RADIUS === */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* === TRANSITIONS === */
    --transition-fast: 200ms ease-in-out;
    --transition-medium: 300ms ease-in-out;
    --transition-slow: 500ms ease-in-out;

    /* === SHADOWS (Updated for light mode) === */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.12);

    /* === BORDER COLORS === */
    --color-border: #E8E4DE;
    --color-border-light: #F5F1EB;
}

/* ============================================================================
   RESET & BASE STYLES
   ============================================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--color-dark);
    color: var(--color-text-primary);
    line-height: 1.6;
    font-size: 16px;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--spacing-md);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--spacing-md);
    color: var(--color-text-secondary);
}

a {
    color: var(--color-blue);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-purple);
}

/* ============================================================================
   BUTTONS
   ============================================================================ */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all var(--transition-medium);
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--color-purple);
    color: white;
}

.btn-primary:hover {
    background-color: var(--color-purple-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(139, 92, 246, 0.3);
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--color-blue);
    color: var(--color-blue);
}

.btn-secondary:hover {
    background-color: var(--color-blue);
    color: white;
}

.btn-danger {
    background-color: var(--color-error);
    color: white;
}

.btn-danger:hover {
    background-color: #DC2626;
}

/* ============================================================================
   CARDS
   ============================================================================ */
.card {
    background-color: var(--color-slate);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-medium), box-shadow var(--transition-medium);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* ============================================================================
   FORM INPUTS
   ============================================================================ */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-secondary);
    font-weight: 500;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    width: 100%;
    position: relative;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }

/* ============================================================================
   FLASH MESSAGES
   ============================================================================ */
.flash-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.flash-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
    backdrop-filter: blur(10px);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.flash-message.flash-success {
    background-color: rgba(16, 185, 129, 0.9);
    border-left: 4px solid var(--color-success);
}

.flash-message.flash-error {
    background-color: rgba(239, 68, 68, 0.9);
    border-left: 4px solid var(--color-error);
}

.flash-message.flash-warning {
    background-color: rgba(245, 158, 11, 0.9);
    border-left: 4px solid var(--color-warning);
}

.flash-message.flash-info {
    background-color: rgba(59, 130, 246, 0.9);
    border-left: 4px solid var(--color-info);
}

.flash-icon {
    font-size: 1.5rem;
    font-weight: bold;
}

.flash-text {
    flex: 1;
    color: white;
    font-weight: 500;
}

.flash-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color var(--transition-fast);
}

.flash-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.fade-in {
    animation: fadeIn var(--transition-medium);
}

.spinner {
    border: 3px solid rgba(139, 92, 246, 0.1);
    border-top-color: var(--color-purple);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

/* ============================================================================
   ADVANCED ANIMATIONS & TRANSITIONS (Milestone 5)
   ============================================================================ */

/* Page Transitions */
body {
    opacity: 0;
    transition: opacity 300ms ease-in-out;
}

body.page-loaded {
    opacity: 1;
}

body.page-leaving {
    opacity: 0;
}

/* Shake Animation for Errors */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

/* Ripple Effect */
.btn-primary, .btn-secondary, .btn-danger {
    position: relative;
    overflow: hidden;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0);
    animation: ripple-animation 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Button Loading State */
.btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.button-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 8px;
}

/* Toast Notifications Enhancement */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--color-slate);
    color: var(--color-text-primary);
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 500px;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 10000;
    border-left: 4px solid var(--color-info);
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-success {
    border-left-color: var(--color-success);
}

.toast-error {
    border-left-color: var(--color-error);
}

.toast-warning {
    border-left-color: var(--color-warning);
}

.toast-info {
    border-left-color: var(--color-info);
}

.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
}

.toast-success .toast-icon {
    color: var(--color-success);
}

.toast-error .toast-icon {
    color: var(--color-error);
}

.toast-warning .toast-icon {
    color: var(--color-warning);
}

.toast-info .toast-icon {
    color: var(--color-info);
}

.toast-message {
    flex: 1;
    font-size: 0.9375rem;
    line-height: 1.4;
}

/* Progress Bar Animation */
.progress-bar-animated {
    transition: width 1s ease-out;
}

/* Pulse Animation for Credit Balance */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(139, 92, 246, 0);
    }
}

.credit-pulse {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Slide In Animations */
@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.slide-in-left {
    animation: slideInLeft 0.4s ease-out;
}

.slide-in-right {
    animation: slideInRight 0.4s ease-out;
}

.slide-in-up {
    animation: slideInUp 0.4s ease-out;
}

/* Scale Animation */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.3s ease-out;
}

/* Shimmer Effect for Hover */
@keyframes shimmer {
    0% {
        background-position: -1000px 0;
    }
    100% {
        background-position: 1000px 0;
    }
}

.shimmer-hover {
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
    background-size: 1000px 100%;
    transition: background-position 0.6s ease;
}

.shimmer-hover:hover {
    animation: shimmer 1.5s ease-in-out infinite;
}

/* Counter Animation */
.count-up {
    display: inline-block;
    transition: transform 0.3s ease;
}

.count-up.updating {
    transform: scale(1.1);
}

/* Modal Fade In */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal.show {
    animation: modalFadeIn 0.3s ease-out;
}

/* Loading Skeleton */
@keyframes skeleton-loading {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-slate) 0px,
        rgba(0, 0, 0, 0.02) 40px,
        var(--color-slate) 80px
    );
    background-size: 200px 100%;
    animation: skeleton-loading 1.2s ease-in-out infinite;
}

/* ============================================================================
   ACCESSIBILITY ENHANCEMENTS (Milestone 5)
   ============================================================================ */

/* Skip to Content Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-purple);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 0 0 var(--radius-md) 0;
    z-index: 100;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus Indicators for Keyboard Navigation */
body.keyboard-nav *:focus {
    outline: 2px solid var(--color-purple);
    outline-offset: 2px;
}

body:not(.keyboard-nav) *:focus {
    outline: none;
}

/* High Contrast Focus for Form Elements */
input:focus,
textarea:focus,
select:focus,
button:focus {
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --color-dark: #000000;
        --color-slate: #1a1a1a;
        --color-text-primary: #ffffff;
        --color-text-secondary: #e0e0e0;
    }

    .btn-primary {
        border: 2px solid white;
    }

    .btn-secondary {
        border-width: 2px;
    }
}

/* ============================================================================
   ERROR STATES & VALIDATION (Milestone 5)
   ============================================================================ */

/* Input Error State */
input.error,
textarea.error,
select.error {
    border-color: var(--color-error) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

input.error:focus,
textarea.error:focus,
select.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

/* Inline Error Messages */
.error-message {
    color: var(--color-error);
    font-size: 0.875rem;
    margin-top: var(--spacing-xs);
    display: flex;
    align-items: center;
    gap: 4px;
}

.error-message::before {
    content: "⚠";
    font-size: 1rem;
}

/* Success State */
input.success,
textarea.success {
    border-color: var(--color-success) !important;
}

/* ============================================================================
   EMPTY STATES (Milestone 5)
   ============================================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2xl);
    text-align: center;
    color: var(--color-text-tertiary);
    min-height: 300px;
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-lg);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-sm);
}

.empty-state-description {
    font-size: 0.9375rem;
    max-width: 400px;
    margin-bottom: var(--spacing-lg);
}

/* ============================================================================
   PERFORMANCE OPTIMIZATIONS (Milestone 5)
   ============================================================================ */

/* GPU Acceleration for Animations */
.btn,
.toast,
.modal,
.card {
    will-change: transform;
    transform: translateZ(0);
}

/* Lazy Loaded Images */
img[data-src] {
    opacity: 0;
    transition: opacity 0.3s;
}

img[data-src].loaded {
    opacity: 1;
}

/* Content Loading Placeholder */
.loading-placeholder {
    background: var(--color-slate);
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* Page Loader with Animated Logo */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.page-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.page-loader-logo {
    width: 100px;
    height: 100px;
    animation: logoFloat 2.6s ease-in-out infinite;
    transform-origin: 50% 50%;
    filter: drop-shadow(0 10px 20px rgba(139, 92, 246, 0.6));
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-20px) scale(1.1);
    }
}

.page-loader-text {
    margin-top: 32px;
    color: var(--color-text-secondary);
    font-size: 1rem;
    animation: pulse 2s ease-in-out infinite;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 768px) {
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }

    .toast {
        bottom: 12px;
        right: 12px;
        left: 12px;
        min-width: auto;
    }

    /* Stack buttons vertically on mobile */
    .button-group {
        flex-direction: column;
    }

    .button-group .btn {
        width: 100%;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    body {
        font-size: 15px;
    }
}

/* Print Styles */
@media print {
    .toast,
    .modal,
    .skip-link,
    button,
    .btn {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }
}
