:root {
    --primary: #727373;
    --bg-dark: #0a0a0a;
    --bg-card: #1a1a1a;
    --bg-hover: #252525;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --accent: #d4af37;
    --accent-dim: #8b7355;
    --border: #2a2a2a;
    --success: #4ade80;
}

[data-theme="light"] {
    --primary: #5a5a5a;
    --bg-dark: #f5f5f5;
    --bg-card: #ffffff;
    --bg-hover: #e8e8e8;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --accent: #d4af37;
    --accent-dim: #8b7355;
    --border: #e0e0e0;
    --success: #22c55e;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'IBM Plex Sans', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 50%, rgba(114, 115, 115, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(212, 175, 55, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.geometric-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.geometric-shape {
    position: absolute;
    border: 1px solid rgba(114, 115, 115, 0.1);
    animation: float 20s infinite ease-in-out;
}

.shape-1 {
    width: 300px;
    height: 300px;
    top: 10%;
    left: 5%;
    transform: rotate(45deg);
    animation-delay: 0s;
}

.shape-2 {
    width: 200px;
    height: 200px;
    top: 60%;
    right: 10%;
    border-radius: 50%;
    animation-delay: 5s;
}

.shape-3 {
    width: 150px;
    height: 150px;
    bottom: 15%;
    left: 15%;
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
    animation-delay: 10s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
        opacity: 0.1;
    }
    50% {
        transform: translateY(-30px) rotate(180deg);
        opacity: 0.2;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeInDown 0.8s ease-out;
    position: relative;
}

.header-controls {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 1.2rem;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateY(-2px);
}

h1 {
    font-family: 'Amiri', serif;
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.quick-actions {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    animation: fadeInDown 0.8s ease-out 0.1s backwards;
}

.quick-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.quick-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary);
}

.translation-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem;
    margin-bottom: 3rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.8s ease-out 0.2s backwards;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.input-group {
    margin-bottom: 2rem;
}

label {
    display: block;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.char-counter {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.char-counter.warning {
    color: #f59e0b;
}

.char-counter.danger {
    color: #ef4444;
}

.textarea-wrapper {
    position: relative;
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    padding-right: 50px;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: all 0.3s ease;
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(114, 115, 115, 0.1);
}

.voice-btn {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.voice-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.voice-btn.listening {
    animation: pulse 1.5s infinite;
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.context-field {
    margin-top: 1rem;
}

.context-field input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-dark);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.context-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(114, 115, 115, 0.1);
}

.button-group {
    display: flex;
    gap: 0.75rem;
}

.translate-btn {
    flex: 1;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary), var(--accent-dim));
    color: var(--text-primary);
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.05em;
}

.translate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.translate-btn:hover::before {
    left: 100%;
}

.translate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(114, 115, 115, 0.3);
}

.translate-btn:active {
    transform: translateY(0);
}

.translate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.clear-btn {
    padding: 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: var(--bg-hover);
    color: #ef4444;
    border-color: #ef4444;
}

.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin: 0 auto;
}

.translate-btn.loading .spinner {
    display: inline-block;
    margin-right: 0.5rem;
}

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

.results {
    display: none;
    margin-top: 2rem;
}

.results.show {
    display: block;
    animation: fadeInUp 0.6s ease-out;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.results-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

.results-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--primary);
}

.translation-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.translation-card {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.translation-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--accent), var(--primary));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.translation-card:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.translation-card:hover::before {
    opacity: 1;
}

.translation-card.favorited::before {
    opacity: 1;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.variant-label {
    font-size: 0.8rem;
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.favorite-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.favorite-btn:hover,
.favorite-btn.active {
    color: #f59e0b;
    transform: scale(1.2);
}

.variation-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: rgba(114, 115, 115, 0.1);
    border-radius: 6px;
    border-left: 2px solid var(--accent-dim);
}

.translation-text {
    font-family: 'Amiri', serif;
    font-size: 1.3rem;
    line-height: 1.8;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    direction: rtl;
    text-align: right;
}

.romanization {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(114, 115, 115, 0.05);
    border-radius: 6px;
    display: none;
}

.romanization.show {
    display: block;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
}

.copy-btn {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.copy-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text-primary);
}

.copy-btn.copied {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.share-btn {
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.share-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--text-primary);
}

.history-section {
    margin-top: 4rem;
    animation: fadeInUp 0.8s ease-out 0.4s backwards;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.history-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

.history-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-box {
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    width: 200px;
    transition: all 0.3s ease;
}

.search-box:focus {
    outline: none;
    border-color: var(--primary);
    width: 250px;
}

.export-btn,
.clear-history-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.export-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--accent);
}

.clear-history-btn:hover {
    background: var(--bg-hover);
    border-color: #ef4444;
    color: #ef4444;
}

.history-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--primary);
    color: var(--text-primary);
    border-color: var(--primary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.history-item:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.history-original {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.history-translations {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-translation {
    font-family: 'Amiri', serif;
    font-size: 1.1rem;
    color: var(--text-primary);
    direction: rtl;
    text-align: right;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.stats-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close-modal:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.shortcut-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-dark);
    border-radius: 8px;
}

.shortcut-keys {
    display: flex;
    gap: 0.25rem;
}

.key {
    padding: 0.25rem 0.5rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: monospace;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    z-index: 1001;
    display: none;
    animation: slideInRight 0.3s ease-out;
}

.toast.show {
    display: block;
}

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

.install-prompt {
    background: linear-gradient(135deg, #1e40af, #7c3aed);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    display: none;
    align-items: center;
    justify-content: space-between;
    animation: fadeInDown 0.8s ease-out 0.3s backwards;
}

.install-prompt.show {
    display: flex;
}

.install-text {
    color: white;
    font-weight: 500;
}

.install-btn {
    padding: 0.5rem 1rem;
    background: white;
    color: #1e40af;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .translation-section {
        padding: 1.5rem;
    }

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

    h1 {
        font-size: 2rem;
    }

    .header-controls {
        position: static;
        margin-top: 1rem;
        justify-content: center;
    }

    .history-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-box {
        flex: 1;
        width: auto;
    }

    .search-box:focus {
        width: auto;
    }

    .button-group {
        flex-direction: column;
    }

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

    .toast {
        left: 1rem;
        right: 1rem;
        bottom: 1rem;
    }
}
