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

:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #6366f1;
    --accent-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    
    --container-max-width: 1200px;
    --content-max-width: 800px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
}

/* Navigation */
.navbar {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 4rem;
}

.nav-logo a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.nav-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    box-shadow: var(--shadow-md);
}

.nav-menu.active {
    display: block;
}

.nav-category {
    margin-bottom: 1.5rem;
}

.nav-category h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nav-link {
    display: block;
    padding: 0.5rem 0;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-link:hover {
    color: var(--primary-color);
}

.nav-toggle {
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-secondary);
}

.nav-toggle:hover {
    color: var(--text-primary);
}

/* Main content */
.main-content {
    min-height: calc(100vh - 4rem);
}

/* Hero section */
.hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 4rem 1rem;
}

.hero-container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-cta {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
    line-height: 1;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: white;
    color: var(--primary-color);
    border: 2px solid white;
}

.btn-secondary:hover {
    background-color: transparent;
    color: white;
}

.btn-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background-color: var(--primary-color);
    color: white;
}

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

.btn-success:hover {
    background-color: #059669;
}

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

/* Tools section */
.tools-section {
    padding: 4rem 1rem;
    background-color: var(--bg-secondary);
}

.tools-container {
    max-width: var(--container-max-width);
    margin: 0 auto;
}

.tools-section h2 {
    text-align: center;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.tool-category {
    margin-bottom: 4rem;
}

.tool-category h3 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 2rem;
    color: var(--text-primary);
}

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

.tool-card {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.tool-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.tool-card.featured {
    border-color: var(--primary-color);
    position: relative;
}

.tool-card.featured::before {
    content: 'Popular';
    position: absolute;
    top: -0.5rem;
    right: 1rem;
    background-color: var(--primary-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.tool-icon {
    width: 3rem;
    height: 3rem;
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.tool-card h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.tool-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.tool-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: gap 0.2s;
}

.tool-link:hover {
    gap: 0.75rem;
}

/* Features section */
.features {
    padding: 4rem 1rem;
    background-color: var(--bg-primary);
}

.features-container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    text-align: center;
}

.features h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature {
    padding: 1.5rem;
}

.feature i {
    width: 3rem;
    height: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.feature h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.feature p {
    color: var(--text-secondary);
}

/* Tool pages */
.tool-container {
    max-width: var(--content-max-width);
    margin: 0 auto;
    padding: 2rem 1rem;
}

.tool-header {
    text-align: center;
    margin-bottom: 3rem;
}

.tool-header h1 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.tool-header p {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

/* Forms */
.tool-form {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: border-color 0.2s;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(79 70 229 / 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.text-stats {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Result containers */
.result-container {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    margin-bottom: 2rem;
}

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

.result-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Tabs */
.result-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

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

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Content areas */
.solution-content,
.summary-content,
.corrected-content,
.answer-content,
.rewritten-content {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    line-height: 1.7;
    white-space: pre-wrap;
}

/* Examples and tips */
.tool-examples,
.tool-tips,
.popular-questions {
    margin-top: 2rem;
}

.tool-examples h3,
.tool-tips h3,
.popular-questions h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.examples-grid,
.questions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.example-card,
.question-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.example-card:hover,
.question-card:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tool-tips ul {
    list-style-position: inside;
    color: var(--text-secondary);
    line-height: 1.7;
}

.tool-tips li {
    margin-bottom: 0.5rem;
}

/* Error handling */
.error-container {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 2rem;
}

.error-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--danger-color);
    font-weight: 500;
}

/* Loading states */
.btn-loading {
    display: none;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn.loading .btn-loading i {
    animation: spin 1s linear infinite;
}

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

/* Flashcard specific styles */
.flashcard-container {
    perspective: 1000px;
    margin-bottom: 2rem;
}

.flashcard {
    width: 100%;
    height: 300px;
    position: relative;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--border-color);
    background-color: var(--bg-primary);
}

.flashcard-back {
    transform: rotateY(180deg);
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.card-type {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.card-content {
    font-size: 1.125rem;
    line-height: 1.6;
}

.flashcard-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.flashcard-controls h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.controls {
    display: flex;
    gap: 0.5rem;
}

.flashcard-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* Quiz specific styles */
.quiz-container {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.quiz-header {
    margin-bottom: 2rem;
}

.quiz-progress {
    margin-top: 1rem;
}

.progress-bar {
    width: 100%;
    height: 0.5rem;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-top: 0.5rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
    width: 10%;
}

.question-container {
    margin-bottom: 2rem;
}

.question-text {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    line-height: 1.6;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.option {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    background-color: var(--bg-primary);
}

.option:hover {
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
}

.option.selected {
    border-color: var(--primary-color);
    background-color: var(--primary-color);
    color: white;
}

.option.correct {
    border-color: var(--success-color);
    background-color: var(--success-color);
    color: white;
}

.option.incorrect {
    border-color: var(--danger-color);
    background-color: var(--danger-color);
    color: white;
}

.question-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

/* Quiz results */
.quiz-results {
    text-align: center;
}

.score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
}

.score-circle {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--success-color), var(--primary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
}

.score-details h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.results-breakdown {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
}

/* Essay grader specific */
.grade-overview {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.grade-score {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.grade-breakdown {
    flex: 1;
}

.grade-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.grade-item:last-child {
    border-bottom: none;
}

.grade-value {
    font-weight: 600;
    color: var(--primary-color);
}

.feedback-sections {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.feedback-section h4 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.feedback-content {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Footer */
.footer {
    background-color: var(--text-primary);
    color: white;
    margin-top: 4rem;
}

.footer-container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 3rem 1rem 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.footer-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.footer-section p {
    opacity: 0.7;
    line-height: 1.6;
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 0.5rem;
}

.footer-section a {
    color: white;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.footer-section a:hover {
    opacity: 1;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1rem;
    text-align: center;
    opacity: 0.7;
}

/* Responsive design */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .hero-cta {
        flex-direction: column;
        align-items: center;
    }
    
    .nav-menu {
        display: none;
    }
    
    .tools-grid {
        grid-template-columns: 1fr;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .tool-header h1 {
        font-size: 2rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .flashcard-controls {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
    }
    
    .question-actions {
        flex-direction: column;
    }
    
    .score-display {
        flex-direction: column;
        text-align: center;
    }
    
    .grade-overview {
        flex-direction: column;
    }
    
    .flashcard-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .tool-container {
        padding: 1rem;
    }
    
    .tool-form {
        padding: 1.5rem;
    }
    
    .result-container {
        padding: 1.5rem;
    }
    
    .flashcard {
        height: 250px;
    }
    
    .flashcard-front,
    .flashcard-back {
        padding: 1.5rem;
    }
    
    .examples-grid,
    .questions-grid {
        grid-template-columns: 1fr;
    }
}
