/* ============================================
   RESET & BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette - Modern & Professional */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #ec4899;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    
    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-light: #cbd5e1;
    
    /* Borders */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -1px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -2px rgba(15, 23, 42, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 10px 10px -5px rgba(15, 23, 42, 0.04);
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: var(--space-xl);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* ============================================
   HEADER
   ============================================ */

.header {
    text-align: center;
    margin-bottom: var(--space-3xl);
    animation: slideDown 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.header-badge {
    display: inline-block;
    padding: var(--space-sm) var(--space-md);
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-full);
    color: white;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    letter-spacing: 0.5px;
}

.header-content h1 {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: 700;
    color: white;
    margin-bottom: var(--space-md);
    letter-spacing: -0.5px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.header-content p {
    font-size: clamp(1rem, 3vw, 1.25rem);
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   MAIN CONTENT LAYOUT
   ============================================ */

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    flex: 1;
    animation: slideUp 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.form-section, .output-section {
    display: flex;
    flex-direction: column;
}

/* ============================================
   FORM CARD
   ============================================ */

.form-card {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-xl);
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.form-header {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 2px solid var(--border-light);
}

.form-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.form-subtitle {
    display: block;
    color: var(--text-tertiary);
    font-size: 0.9rem;
    font-weight: 400;
}

/* ============================================
   FORM GROUPS & INPUTS
   ============================================ */

.form-group {
    margin-bottom: var(--space-lg);
    display: flex;
    flex-direction: column;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
}

.required {
    color: var(--error);
    font-weight: 700;
}

.optional {
    color: var(--text-tertiary);
    font-weight: 400;
    font-size: 0.85rem;
}

.input-wrapper {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    position: relative;
}

.input-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    flex-shrink: 0;
    font-size: 1.25rem;
    margin-top: 0.5rem;
}

.input-wrapper input[type="text"],
.input-wrapper input[type="email"],
.input-wrapper textarea {
    flex: 1;
    padding: var(--space-md);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-family: inherit;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.input-wrapper input[type="text"]::placeholder,
.input-wrapper input[type="email"]::placeholder,
.input-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

.input-wrapper input[type="text"]:focus,
.input-wrapper input[type="email"]:focus,
.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    background: var(--bg-primary);
}

.input-wrapper textarea {
    resize: vertical;
    min-height: 100px;
}

.helper-text {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    margin-top: var(--space-xs);
    font-weight: 400;
}

/* ============================================
   FILE UPLOAD
   ============================================ */

.file-upload {
    position: relative;
    margin-bottom: var(--space-sm);
}

.file-upload input[type="file"] {
    display: none;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-lg);
    border: 2px dashed var(--primary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    background: rgba(99, 102, 241, 0.05);
    text-align: center;
}

.file-icon {
    font-size: 2rem;
    display: block;
}

.file-text {
    display: block;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.file-size {
    display: block;
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.file-label:hover {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary-dark);
    transform: translateY(-2px);
}

.file-label:active {
    transform: translateY(0);
}

.file-name {
    color: var(--success);
    font-size: 0.9rem;
    margin-top: var(--space-sm);
}

/* ============================================
   AI MODE SELECTION
   ============================================ */

.ai-mode-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-top: var(--space-md);
}

.mode-card {
    position: relative;
    cursor: pointer;
}

.mode-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.mode-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    background: var(--bg-primary);
}

.mode-emoji {
    font-size: 1.75rem;
}

.mode-text {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.mode-title {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.mode-desc {
    display: block;
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.mode-card input[type="radio"]:checked + .mode-content {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.mode-card:hover .mode-content {
    border-color: var(--primary-light);
    background: var(--bg-secondary);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
}

.btn-icon {
    font-size: 1.1rem;
}

.btn-text {
    display: block;
}

/* Primary Button */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Secondary Button */
.btn-secondary {
    background: var(--bg-primary);
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: calc(0.625rem - 2px) 1.25rem;
    font-weight: 600;
}

.btn-secondary:hover {
    background: var(--bg-secondary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Icon Secondary Button */
.btn-icon-secondary {
    width: 2.5rem;
    height: 2.5rem;
    padding: 0;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    color: var(--primary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-icon-secondary:hover {
    background: var(--border);
    transform: scale(1.05);
}

.btn-icon-secondary .icon {
    font-size: 1.25rem;
}

/* ============================================
   OUTPUT SECTION
   ============================================ */

.output-card {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-xl);
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 0, 0, 0.05);
    animation: slideRight 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.output-card.hidden {
    display: none;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 2px solid var(--border-light);
}

.output-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.output-content {
    flex: 1;
    overflow-y: auto;
    margin-bottom: var(--space-lg);
    padding: var(--space-lg);
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    max-height: 100%;
}

.output-content::-webkit-scrollbar {
    width: 8px;
}

.output-content::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.output-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-lg);
}

.output-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

.letter-content {
    line-height: 1.8;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.output-footer {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.output-footer .btn {
    flex: 1;
    min-width: 140px;
}

/* ============================================
   EMPTY & LOADING STATES
   ============================================ */

.empty-state {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-xl);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.05);
    gap: var(--space-lg);
    animation: fadeIn 0.5s var(--transition);
}

.empty-icon {
    font-size: 4rem;
    opacity: 0.8;
}

.empty-state h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin: 0;
}

.empty-state p {
    color: var(--text-secondary);
    margin: 0;
    max-width: 300px;
}

/* Loading State */
.loading-state {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-xl);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    animation: fadeIn 0.3s var(--transition);
    gap: var(--space-lg);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.loading-state.hidden {
    display: none;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-right-color: var(--secondary);
    border-radius: 50%;
    animation: spin 1.5s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-state h3 {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin: 0;
}

.loading-state p {
    color: var(--text-secondary);
    margin: 0;
}

/* Error State */
.error-state {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-xl);
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    animation: slideUp 0.4s var(--transition);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.error-state.hidden {
    display: none;
}

.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

.error-icon {
    font-size: 4rem;
}

.error-state h3 {
    color: var(--error);
    font-size: 1.25rem;
    margin: 0;
}

.error-state p {
    color: var(--text-secondary);
    margin: 0;
    max-width: 400px;
}

/* ============================================
   NOTIFICATIONS
   ============================================ */

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    animation: slideInUp 0.3s var(--transition);
    opacity: 0;
    transform: translateY(100%);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.toast.success {
    background: var(--success);
    color: white;
}

.toast.error {
    background: var(--error);
    color: white;
}

.floating-status {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border-left: 4px solid var(--primary);
    z-index: 999;
    font-size: 0.9rem;
    animation: slideInLeft 0.3s var(--transition);
    opacity: 0;
    transform: translateX(-100%);
    pointer-events: none;
}

.floating-status.show {
    opacity: 1;
    transform: translateX(0);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 1024px) {
    .container {
        padding: var(--space-lg);
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }

    .header-content h1 {
        font-size: 2rem;
    }

    .header-content p {
        font-size: 1rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }

    .header {
        margin-bottom: var(--space-2xl);
    }

    .header-content h1 {
        font-size: 1.75rem;
    }

    .form-card, .output-card, .empty-state, .loading-state, .error-state {
        padding: var(--space-lg);
    }

    .form-header {
        padding-bottom: var(--space-md);
    }

    .ai-mode-group {
        grid-template-columns: 1fr;
    }

    .output-footer {
        flex-direction: column;
    }

    .output-footer .btn {
        width: 100%;
    }

    .output-content {
        max-height: 300px;
    }

    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .floating-status {
        left: 1rem;
        right: 1rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: var(--space-sm);
    }

    .header {
        margin-bottom: var(--space-xl);
    }

    .header-content h1 {
        font-size: 1.5rem;
    }

    .header-content p {
        font-size: 0.95rem;
    }

    .form-card, .output-card {
        padding: var(--space-md);
    }

    .input-wrapper {
        flex-direction: column;
    }

    .input-icon {
        width: 100%;
        margin-top: 0;
    }

    .output-footer {
        gap: var(--space-sm);
    }

    .btn {
        font-size: 0.95rem;
    }

    .mode-card input[type="radio"]:checked + .mode-content {
        box-shadow: none;
    }
}
