:root {
    --primary-color: #3f51b5;
    --accent-color: #ff4081;
    --background-color: #121212;
    --surface-color: rgba(255, 255, 255, 0.05);
    --surface-blur-color: rgba(255, 255, 255, 0.08);
    --text-color: #e0e0e0;
    --muted-text-color: #b0b0b0;
    --border-color: rgba(255, 255, 255, 0.1);
    --font-family: 'Poppins', sans-serif;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background: linear-gradient(135deg, #1f1c2c, #3f3b56);
    background-color: var(--background-color);
    color: var(--text-color);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

#root {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-header {
    padding: 1rem 2rem;
    background: var(--surface-blur-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-color);
    text-shadow: 0 0 10px var(--primary-color);
}

.language-selector {
    display: flex;
    gap: 0.5rem;
    background-color: var(--surface-color);
    padding: 0.25rem;
    border-radius: 8px;
}

.language-selector button {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: var(--muted-text-color);
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: var(--font-family);
    transition: all 0.2s ease-in-out;
}

.language-selector button:hover {
    color: var(--text-color);
    background-color: rgba(255, 255, 255, 0.1);
}

.language-selector button.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
}


.app-container {
    display: flex;
    flex: 1;
}

.sidebar {
    width: 280px;
    background: var(--surface-blur-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    transition: width 0.3s ease;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar h2 {
    margin-top: 0;
    font-size: 1.25rem;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    font-weight: 500;
}

.sidebar nav ul {
    list-style: none;
    padding: 0;
    margin: 1rem 0 0 0;
}

.sidebar nav li {
    margin-bottom: 0.5rem;
}

.sidebar nav button {
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    font-size: 1rem;
    font-family: var(--font-family);
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    color: var(--muted-text-color);
}

.sidebar nav button:hover {
    background-color: var(--surface-color);
    color: var(--text-color);
}

.sidebar nav button.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(63, 81, 181, 0.4);
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.topic-card {
    background: var(--surface-blur-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 2.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    animation: fadeIn 0.5s ease-in-out;
}

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

.topic-card h2 {
    margin-top: 0;
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--text-color);
}

.topic-card .formula {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.2rem;
    color: var(--accent-color);
    margin: 1.5rem 0;
    white-space: nowrap;
    overflow-x: auto;
    border: 1px solid var(--border-color);
}

.topic-card p {
    line-height: 1.7;
    color: var(--muted-text-color);
    font-size: 1.1rem;
}

.function-tester {
    margin-top: 2rem;
    border-top: 1px solid var(--border-color);
    padding-top: 2rem;
}

.tester-with-graph {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: flex-start;
}

.tester-controls {
    display: flex;
    flex-direction: column;
}

.graph-container {
    height: 400px;
    background-color: rgba(0,0,0,0.1);
    border-radius: 8px;
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.function-tester h3 {
    margin-top: 0;
    font-size: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.input-item {
    display: flex;
    flex-direction: column;
}

.input-item label {
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--muted-text-color);
}

.input-item input {
    padding: 0.75rem;
    font-size: 1rem;
    font-family: var(--font-family);
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    color: var(--text-color);
    width: 100%;
    box-sizing: border-box;
}

.input-item input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(63, 81, 181, 0.5);
}

.calculate-btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(45deg, var(--accent-color), var(--primary-color));
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    margin-top: 1rem;
}

.calculate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.result {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: rgba(63, 81, 181, 0.1);
    border: 1px solid rgba(63, 81, 181, 0.3);
    border-radius: 8px;
    font-size: 1.2rem;
    font-weight: 500;
    color: #a9b1ec;
}

.result-extra {
    margin-top: 0.5rem;
    padding: 0.5rem 1rem;
    background-color: rgba(255, 64, 129, 0.1);
    border: 1px solid rgba(255, 64, 129, 0.3);
    border-radius: 6px;
    font-size: 1rem;
    color: #ff80ab;
}

.error-message {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: rgba(211, 47, 47, 0.1);
    border: 1px solid rgba(211, 47, 47, 0.3);
    border-radius: 6px;
    font-size: 1.1rem;
    color: #f48fb1;
}

.statistics-tester textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 80px;
    padding: 0.75rem;
    font-size: 1rem;
    font-family: var(--font-family);
    border: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    color: var(--text-color);
    resize: vertical;
    margin-bottom: 1rem;
}

.statistics-results ul {
    list-style: none;
    padding: 0;
}

.statistics-results li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .tester-with-graph {
        grid-template-columns: 1fr;
    }
    .graph-container {
        height: 300px;
    }
}

@media (max-width: 768px) {
    .app-header {
      flex-direction: column;
      gap: 1rem;
    }
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
        max-height: none;
        overflow-y: visible;
    }

    .sidebar h2 {
        display: none;
    }

    .sidebar nav ul {
      display: flex;
      flex-wrap: wrap;
      gap: 0.5rem;
      margin-top: 0;
    }
    
    .sidebar nav button {
      padding: 0.5rem 1rem;
      flex-grow: 1;
    }

    .main-content {
        padding: 1.5rem;
    }

    .topic-card {
        padding: 1.5rem;
    }

    .topic-card h2 {
        font-size: 1.75rem;
    }
}

/* RTL Support */
[dir="rtl"] .app-container {
    flex-direction: row-reverse;
}

[dir="rtl"] .sidebar {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

[dir="rtl"] .sidebar nav button,
[dir="rtl"] .topic-card,
[dir="rtl"] .function-tester,
[dir="rtl"] .input-item label,
[dir="rtl"] .statistics-tester label {
    text-align: right;
}

[dir="rtl"] .statistics-results li {
    flex-direction: row-reverse;
}
[dir="rtl"] .input-item input, 
[dir="rtl"] .statistics-tester textarea {
    text-align: right;
}

[dir="rtl"] .app-header h1 {
    text-align: right;
}
