/* ============================================
   CSS Variables & Reset
   ============================================ */
:root {
    /* Light Theme Colors */
    --bg-primary: #f8f9fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f3f5;
    --text-primary: #212529;
    --text-secondary: #495057;
    --text-tertiary: #6c757d;
    --border-color: #dee2e6;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    
    /* Fonts */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-hindi: 'Noto Sans Devanagari', sans-serif;
    
    /* Transitions */
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-color: #334155;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --primary-light: #312e81;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color var(--transition-slow), color var(--transition-slow);
}

/* ============================================
   Theme Toggle
   ============================================ */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    transition: all var(--transition-base);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.theme-toggle svg {
    color: var(--text-primary);
}

.sun-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: block;
}

[data-theme="dark"] .moon-icon {
    display: none;
}

/* ============================================
   Container & Layout
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ============================================
   Header
   ============================================ */
.header {
    text-align: center;
    padding: 40px 20px 30px;
}

.header h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* ============================================
   Translator Section
   ============================================ */
.translator-section {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    margin: 30px 0;
    align-items: start;
}

.input-panel,
.output-panel {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

.input-panel:hover,
.output-panel:hover {
    box-shadow: var(--shadow-lg);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.char-count {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    font-weight: 500;
}

.text-area {
    width: 100%;
    min-height: 200px;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    resize: vertical;
    transition: all var(--transition-base);
}

.text-area:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.text-area::placeholder {
    color: var(--text-tertiary);
}

.output {
    border: 2px dashed var(--border-color);
    font-family: var(--font-hindi);
    font-size: 1.1rem;
    line-height: 1.8;
    background: var(--bg-tertiary);
    overflow-y: auto;
    position: relative;
}

.placeholder {
    color: var(--text-tertiary);
    font-style: italic;
    font-family: var(--font-primary);
}

/* ============================================
   Arrow Icon
   ============================================ */
.arrow-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 80px;
}

.arrow-icon svg {
    color: var(--primary-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* ============================================
   Buttons
   ============================================ */
.button-group {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    flex: 1;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-primary);
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-base);
    border-radius: 8px;
}

.btn-icon:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--primary-color);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
    transition: all var(--transition-base);
}

.btn-text:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ============================================
   Loading Spinner
   ============================================ */
.loading {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-secondary);
}

.loading.active {
    display: flex;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   History Section
   ============================================ */
.history-section {
    margin: 40px 0;
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.history-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    transition: all var(--transition-base);
    cursor: pointer;
}

.history-item:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--primary-color);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.history-delete {
    background: none;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    padding: 4px;
    opacity: 0;
    transition: all var(--transition-base);
}

.history-item:hover .history-delete {
    opacity: 1;
}

.history-delete:hover {
    transform: scale(1.2);
}

.history-text {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    font-size: 0.95rem;
}

.history-english {
    color: var(--text-secondary);
}

.history-arrow {
    color: var(--primary-color);
    font-weight: bold;
}

.history-hindi {
    font-family: var(--font-hindi);
    color: var(--text-primary);
}

.empty-history {
    text-align: center;
    color: var(--text-tertiary);
    padding: 40px;
    font-style: italic;
}

/* ============================================
   Features Section
   ============================================ */
.features-section {
    margin: 50px 0;
    padding: 40px 0;
}

.features-section h3 {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 40px;
    color: var(--text-primary);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.feature-card svg {
    color: var(--primary-color);
    margin-bottom: 16px;
}

.feature-card h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ============================================
   Toast Notification
   ============================================ */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 1001;
    min-width: 250px;
    animation: slideIn 0.3s ease;
}

.toast.show {
    display: flex;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   Footer
   ============================================ */
.footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    border-top: 1px solid var(--border-color);
    margin-top: 60px;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 968px) {
    .translator-section {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    
    .arrow-icon {
        margin-top: 0;
        transform: rotate(90deg);
    }
    
    .theme-toggle {
        top: 12px;
        right: 12px;
        width: 44px;
        height: 44px;
    }
    
    .header {
        padding-top: 60px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 12px;
    }
    
    .header h1 {
        font-size: 1.75rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .input-panel,
    .output-panel {
        padding: 16px;
    }
    
    .text-area {
        min-height: 150px;
        font-size: 0.95rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .history-text {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .history-arrow {
        transform: rotate(90deg);
        text-align: center;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .toast {
        left: 12px;
        right: 12px;
        bottom: 12px;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .theme-toggle,
    .button-group,
    .history-section,
    .features-section,
    .footer {
        display: none;
    }
    
    .translator-section {
        display: block;
    }
    
    .output-panel {
        margin-top: 20px;
    }
}