/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a1a2e 50%, #16213e 100%);
    color: #ffffff;
    min-height: 100vh;
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 0;
}

.title {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(45deg, #00ff99, #00ccff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-shadow: 0 4px 8px rgba(0, 255, 153, 0.3);
}

.title i {
    color: #00ff99;
    margin-right: 15px;
    animation: pulse 2s infinite;
}

.subtitle {
    font-size: 1.1rem;
    color: #a0a0a0;
    font-weight: 300;
}

/* Main content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Input section */
.input-section {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.input-group {
    margin-bottom: 25px;
}

.input-label {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: #00ff99;
}

.input-label i {
    margin-right: 8px;
}

.math-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #ffffff;
    resize: vertical;
    min-height: 80px;
    transition: all 0.3s ease;
    font-family: 'Consolas', 'Monaco', monospace;
}

.math-input:focus {
    outline: none;
    border-color: #00ff99;
    box-shadow: 0 0 20px rgba(0, 255, 153, 0.3);
    background: rgba(0, 0, 0, 0.5);
}

.math-input::placeholder {
    color: #888;
    font-style: italic;
}

/* Button group */
.button-group {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.solve-btn, .clear-btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 150px;
    justify-content: center;
}

.solve-btn {
    background: linear-gradient(45deg, #00ff99, #00ccff);
    color: #000;
    box-shadow: 0 4px 15px rgba(0, 255, 153, 0.4);
}

.solve-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 255, 153, 0.6);
}

.solve-btn:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.clear-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.clear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

/* Solution container */
.solution-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.5s ease-out;
}

.solution-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(0, 255, 153, 0.3);
}

.solution-header h3 {
    color: #00ff99;
    font-size: 1.3rem;
    font-weight: 600;
}

.solution-header i {
    margin-right: 10px;
}

.solution-content {
    color: #e0e0e0;
    font-size: 1rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 40px;
    animation: fadeIn 0.3s ease-in;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #00ff99;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

/* Error container */
.error-container {
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid rgba(255, 0, 0, 0.3);
    border-radius: 10px;
    padding: 20px;
    animation: slideIn 0.5s ease-out;
}

.error-content {
    color: #ff6b6b;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px 0;
    color: #888;
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 40px;
}

.footer i {
    margin-right: 8px;
    color: #00ff99;
}

/* Social links */
.social-links {
    margin-top: 20px;
}

.social-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #00ccff;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    padding: 10px 20px;
    border: 1px solid rgba(0, 204, 255, 0.3);
    border-radius: 25px;
    background: rgba(0, 204, 255, 0.1);
    transition: all 0.3s ease;
}

.social-link:hover {
    color: #ffffff;
    background: rgba(0, 204, 255, 0.2);
    border-color: #00ccff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 204, 255, 0.3);
}

.social-link i {
    font-size: 1.1rem;
    color: inherit;
    margin-right: 0;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

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

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .title {
        font-size: 2.2rem;
    }
    
    .input-section,
    .solution-container {
        padding: 20px;
    }
    
    .button-group {
        flex-direction: column;
        align-items: center;
    }
    
    .solve-btn,
    .clear-btn {
        width: 100%;
        max-width: 250px;
    }
    
    /* Math keyboard responsive */
    .math-keyboard {
        padding: 15px;
    }
    
    .keyboard-row {
        gap: 6px;
    }
    
    .math-key {
        padding: 10px 12px;
        font-size: 0.9rem;
        min-width: 45px;
    }
    
    .keyboard-header h4 {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .math-input {
        font-size: 14px;
    }
    
    /* Math keyboard for very small screens */
    .math-keyboard {
        padding: 10px;
    }
    
    .keyboard-row {
        gap: 4px;
    }
    
    .math-key {
        padding: 8px 10px;
        font-size: 0.8rem;
        min-width: 40px;
    }
    
    .keyboard-header h4 {
        font-size: 0.9rem;
    }
    
    .toggle-btn {
        padding: 6px 10px;
        font-size: 0.9rem;
    }
}

/* MathJax styling */
.MathJax {
    color: #e0e0e0 !important;
}

.MathJax_Display {
    margin: 1em 0 !important;
}

/* Math Keyboard Styles */
.math-keyboard-section {
    margin: 20px 0;
}

.keyboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 5px;
}

.keyboard-header h4 {
    color: #00ff99;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.toggle-btn i {
    transition: transform 0.3s ease;
}

.toggle-btn.collapsed i {
    transform: rotate(180deg);
}

.math-keyboard {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.3s ease;
    overflow: hidden;
}

.math-keyboard.hidden {
    height: 0;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.keyboard-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.math-key {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;
    text-align: center;
    user-select: none;
}

.math-key:hover {
    background: rgba(0, 255, 153, 0.2);
    border-color: #00ff99;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 255, 153, 0.3);
}

.math-key:active {
    transform: translateY(0);
    background: rgba(0, 255, 153, 0.3);
}

.fraction-key {
    background: rgba(0, 204, 255, 0.2);
    border-color: #00ccff;
}

.fraction-key:hover {
    background: rgba(0, 204, 255, 0.3);
    border-color: #00ccff;
}

.backspace-key {
    background: rgba(255, 100, 100, 0.2);
    border-color: rgba(255, 100, 100, 0.5);
    min-width: 60px;
}

.backspace-key:hover {
    background: rgba(255, 100, 100, 0.3);
    border-color: #ff6464;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

::-webkit-scrollbar-thumb {
    background: #00ff99;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #00ccff;
}
