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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #6B7EF7 0%, #9B51E0 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Pages */
.page {
    display: none !important;
}

.page.active {
    display: block !important;
}

/* Auth Page */
#auth-page.active {
    display: flex !important;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
}

#auth-page .container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 450px;
}

/* Logo Styling */
.auth-logo-container {
    text-align: center;
    margin-bottom: 20px;
}

.auth-logo {
    max-width: 300px;
    height: auto;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1em;
}

.form-section {
    display: none;
}

.form-section.active {
    display: block;
}

.form-section h2 {
    margin-bottom: 20px;
    color: #333;
}

form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

input, select {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input:focus, select:focus {
    outline: none;
    border-color: #6B7EF7;
}

.btn-primary {
    padding: 12px;
    background: linear-gradient(135deg, #6B7EF7 0%, #9B51E0 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-secondary {
    padding: 8px 16px;
    background: white;
    color: #6B7EF7;
    border: 2px solid #6B7EF7;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #6B7EF7;
    color: white;
}

.switch-form {
    text-align: center;
    margin-top: 15px;
    color: #666;
}

.switch-form a {
    color: #6B7EF7;
    text-decoration: none;
    font-weight: 600;
}

.forgot-password {
    text-align: right;
    margin-top: 10px;
    margin-bottom: 5px;
}

.forgot-password a {
    color: #6B7EF7;
    text-decoration: none;
    font-size: 14px;
}

.forgot-password a:hover {
    text-decoration: underline;
}

.error-message {
    color: #e74c3c;
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px;
    display: none;
}

.error-message.show {
    display: block;
    background: #ffebee;
}

.status-message {
    padding: 8px 0;
    margin-top: 10px;
    display: none;
    font-size: 14px;
    text-align: center;
}

.status-message.show {
    display: block;
}

.status-message.success {
    color: #10b981;
}

.status-message.loading {
    color: #6B7EF7;
}

.status-message.error {
    color: #ef4444;
}

/* Navbar */
.navbar {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    color: #6B7EF7;
    font-size: 1.5em;
}

.navbar-logo {
    height: 50px;
    width: auto;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

#user-name {
    font-weight: 600;
    color: #333;
}

.nav-link {
    color: #6B7EF7;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
    cursor: pointer;
}

.nav-link:hover {
    background-color: #f3f4f6;
    color: #9B51E0;
}

/* Dashboard */
#dashboard-page {
    background: #f5f5f5;
    min-height: 100vh;
}

#dashboard-page .container {
    padding-top: 30px;
}

.section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.section h2 {
    margin-bottom: 20px;
    color: #333;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #6B7EF7 0%, #9B51E0 100%);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    color: white;
}

.stat-card.streak {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.stat-value {
    font-size: 2.5em;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9em;
    opacity: 0.9;
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.category-card {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s;
}

.category-card:hover {
    border-color: #6B7EF7;
    transform: translateY(-2px);
}

.category-name {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 10px;
    text-transform: capitalize;
}

.category-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
}

/* Dashboard Charts */
.dashboard-chart-container {
    background: white;
    padding: 25px;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.dashboard-chart-container h3 {
    margin: 0 0 20px 0;
    color: #374151;
    font-size: 18px;
    font-weight: 600;
}

/* Progress Bar Styles */
.progress-bar-container {
    padding: 20px 0;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 14px;
    color: #6b7280;
}

.progress-labels span:last-child {
    font-weight: 600;
    color: #374151;
}

.progress-bar-wrapper {
    padding: 20px 0;
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 40px;
    background: #f3f4f6;
    border-radius: 20px;
    overflow: visible;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6B7EF7 0%, #9B51E0 100%);
    border-radius: 20px;
    transition: width 0.5s ease;
}

.progress-marker {
    position: absolute;
    top: -30px;
    transform: translateX(-50%);
}

.progress-marker span {
    display: block;
    padding: 5px 12px;
    background: white;
    border: 2px solid #6B7EF7;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #6B7EF7;
    white-space: nowrap;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.progress-marker.target span {
    border-color: #10b981;
    color: #10b981;
}

.progress-marker.current::after,
.progress-marker.target::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    height: 35px;
    background: currentColor;
}

.category-score {
    font-size: 1.5em;
    font-weight: bold;
    color: #6B7EF7;
}

/* Task Generator */
.task-generator {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.task-generator select {
    flex: 1;
    min-width: 150px;
}

.task-generator button {
    flex: 0 0 auto;
}

/* Tasks List */
.tasks-list {
    display: grid;
    gap: 15px;
}

.task-item {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.task-item:hover {
    border-color: #6B7EF7;
    transform: translateX(5px);
}

.task-item.completed {
    background: #f0f9ff;
    border-color: #4ade80;
}

.task-info h3 {
    margin-bottom: 5px;
}

.task-meta {
    display: flex;
    gap: 10px;
    font-size: 0.85em;
    color: #666;
}

.task-badge {
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 0.8em;
    font-weight: 600;
}

.badge-difficulty {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-category {
    background: #f3e5f5;
    color: #6a1b9a;
}

.badge-completed {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    overflow: auto;
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 20px auto;
    padding: 30px;
    border-radius: 15px;
    width: 95%;
    max-width: 1200px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

#task-detail h3 {
    color: #6B7EF7;
    margin-bottom: 15px;
}

#task-detail .task-prompt {
    background: #f5f5f5;
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
    white-space: pre-wrap;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

#task-detail textarea {
    width: 100%;
    min-height: 150px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
}

.word-count {
    text-align: right;
    font-size: 14px;
    color: #666;
    margin-top: 5px;
    margin-bottom: 15px;
}

.submission-result {
    margin-top: 20px;
    padding: 20px;
    border-radius: 10px;
    background: #f0f9ff;
}

.score-display {
    font-size: 3em;
    font-weight: bold;
    text-align: center;
    margin: 20px 0;
}

.score-excellent {
    color: #10b981;
}

.score-good {
    color: #3b82f6;
}

.score-fair {
    color: #f59e0b;
}

.score-poor {
    color: #ef4444;
}

.feedback-section {
    margin-top: 15px;
}

.feedback-section h4 {
    margin-bottom: 10px;
    color: #333;
}

.feedback-section p {
    line-height: 1.6;
    color: #666;
}

/* Loading Spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* OAuth Integration */
.divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: #e0e0e0;
}

.divider span {
    background: white;
    padding: 0 15px;
    color: #999;
    font-size: 14px;
    position: relative;
    z-index: 1;
}

.oauth-buttons {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

/* Responsive */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .task-generator {
        flex-direction: column;
    }

    .task-generator select,
    .task-generator button {
        width: 100%;
    }
}

/* Profile Settings Modal */
#profile-modal .modal-content {
    max-width: 700px;
}

.profile-section {
    margin-bottom: 30px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
}

.profile-section h3 {
    margin-bottom: 15px;
    color: #6B7EF7;
}

.profile-input {
    width: 100%;
    padding: 10px;
    margin: 5px 0 15px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.interest-input-wrapper {
    display: flex;
    gap: 10px;
}

.interest-input-wrapper input {
    flex: 1;
}

.interests-tags, .weak-areas-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.interest-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: #6B7EF7;
    color: white;
    border-radius: 20px;
    font-size: 14px;
}

.weak-area-tag {
    display: inline-block;
    padding: 6px 12px;
    background: #fef3c7;
    color: #d97706;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

.remove-tag {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.remove-tag:hover {
    color: #ff6b6b;
}

/* Enhanced Evaluation Display */
.score-breakdown {
    margin: 20px 0;
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.score-item {
    display: flex;
    flex-direction: column;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #6B7EF7;
}

.score-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.score-value {
    font-size: 24px;
    font-weight: bold;
    color: #6B7EF7;
}

.error-item {
    margin: 15px 0;
    padding: 15px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
}

.error-header {
    margin-bottom: 10px;
    color: #d97706;
}

.error-original {
    color: #dc2626;
    margin: 5px 0;
}

.error-corrected {
    color: #10b981;
    margin: 5px 0;
}

.error-explanation, .error-rule, .error-example {
    margin: 5px 0;
    color: #555;
    font-size: 14px;
}

.priority-section {
    margin-top: 15px;
}

.priority-item {
    margin: 15px 0;
    padding: 15px;
    background: #e0e7ff;
    border-radius: 8px;
    border-left: 4px solid #6B7EF7;
}

.priority-item strong {
    display: block;
    margin-bottom: 10px;
    color: #6B7EF7;
}

.priority-item ul {
    margin: 10px 0 10px 20px;
}

.study-plan {
    margin-top: 20px;
    padding: 20px;
    background: #d1fae5;
    border-radius: 8px;
}

.plan-week, .plan-next {
    margin: 15px 0;
}

.plan-week ul {
    margin: 10px 0 10px 20px;
}

/* Loading Animation */
.evaluation-loading {
    text-align: center;
    padding: 40px;
}

.loading-spinner {
    margin: 0 auto 20px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #6B7EF7;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

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

.evaluation-loading p {
    margin: 10px 0;
    color: #666;
}

/* Close modal when clicking outside */
.modal.show {
    display: flex;
}

/* ====================================================================
   CEFR EVALUATION - TAB INTERFACE
   ==================================================================== */

.evaluation-tabs {
    display: flex;
    gap: 2px;
    margin: 20px 0 0 0;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    flex: 1;
    max-width: 250px;
    padding: 12px 24px;
    background: #f5f5f5;
    border: none;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    background: #e0e7ff;
    color: #6B7EF7;
}

.tab-btn.active {
    background: #6B7EF7;
    color: white;
    transform: translateY(2px);
}

.tab-content {
    margin-top: 0;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s;
}

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

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

/* ====================================================================
   CEFR EVALUATION - SCORE DASHBOARD
   ==================================================================== */

.cefr-score-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
    padding: 20px;
    background: linear-gradient(135deg, #6B7EF7 0%, #9B51E0 100%);
    border-radius: 12px;
    color: white;
}

.cefr-score-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.cefr-score-card.overall {
    grid-column: span 2;
    background: rgba(255, 255, 255, 0.25);
}

.cefr-score-label {
    font-size: 12px;
    text-transform: uppercase;
    opacity: 0.9;
    margin-bottom: 8px;
}

.cefr-score-value {
    font-size: 32px;
    font-weight: bold;
}

.cefr-score-value.large {
    font-size: 48px;
}

.cefr-target-level {
    font-size: 14px;
    opacity: 0.95;
    margin-top: 5px;
}

/* ====================================================================
   CEFR EVALUATION - GENERAL ASSESSMENT
   ==================================================================== */

.cefr-general-assessment {
    margin: 20px 0;
    padding: 20px;
    background: #f0f9ff;
    border-left: 4px solid #6B7EF7;
    border-radius: 8px;
}

.cefr-general-assessment h4 {
    color: #6B7EF7;
    margin-bottom: 10px;
}

.cefr-general-assessment p {
    line-height: 1.6;
    color: #333;
}

/* ====================================================================
   CEFR EVALUATION - RADAR CHART
   ==================================================================== */

.cefr-radar-chart-container {
    margin: 30px 0;
    padding: 25px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.cefr-radar-chart-container h4 {
    color: #374151;
    font-size: 18px;
    font-weight: 600;
}

/* ====================================================================
   CEFR EVALUATION - CORRECTIONS BY CATEGORY
   ==================================================================== */

.cefr-corrections-section {
    margin: 20px 0;
}

.cefr-category-block {
    margin: 15px 0;
    padding: 15px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
}

.cefr-category-header {
    font-weight: bold;
    font-size: 16px;
    color: #d97706;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cefr-error-count-badge {
    background: #d97706;
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
}

.cefr-correction-item {
    margin: 10px 0;
    padding: 12px;
    background: white;
    border-radius: 6px;
}

.cefr-correction-original {
    color: #dc2626;
    font-style: italic;
    margin-bottom: 5px;
}

.cefr-correction-fixed {
    color: #10b981;
    font-weight: 600;
    margin-bottom: 5px;
}

.cefr-correction-reason {
    color: #555;
    font-size: 14px;
    margin-bottom: 5px;
}

.cefr-correction-rule {
    color: #6B7EF7;
    font-size: 13px;
    font-style: italic;
}

/* ====================================================================
   CEFR EVALUATION - DIMENSION FEEDBACK
   ==================================================================== */

.cefr-dimension-section {
    margin: 20px 0;
    padding: 15px;
    background: #f9fafb;
    border-left: 4px solid #6B7EF7;
    border-radius: 8px;
}

.cefr-dimension-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.cefr-dimension-title {
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

.cefr-dimension-score {
    font-size: 24px;
    font-weight: bold;
    color: #6B7EF7;
}

.cefr-dimension-feedback {
    color: #666;
    line-height: 1.6;
}

/* ====================================================================
   CEFR EVALUATION - TEXT HIGHLIGHTING
   ==================================================================== */

.cefr-submission-text {
    margin: 20px 0;
    padding: 20px;
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    line-height: 1.8;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.error-highlight {
    background-color: #fee2e2;
    border-bottom: 2px solid #ef4444;
    cursor: pointer;
    position: relative;
    padding: 2px 0;
    transition: all 0.2s;
}

.error-highlight:hover {
    background-color: #fecaca;
    border-bottom-width: 3px;
}

/* ====================================================================
   CEFR EVALUATION - HOVER POPUP
   ==================================================================== */

.error-popup {
    position: absolute;
    background: white;
    border: 2px solid #ef4444;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    min-width: 280px;
    max-width: 400px;
    animation: popupFadeIn 0.2s;
}

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

.error-popup-type {
    display: inline-block;
    background: #ef4444;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.error-popup-corrected {
    color: #10b981;
    font-weight: 600;
    font-size: 15px;
    margin: 8px 0;
}

.error-popup-corrected::before {
    content: '→ ';
    font-weight: normal;
}

.error-popup-reason {
    color: #333;
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.4;
}

.error-popup-rule {
    color: #6B7EF7;
    font-size: 13px;
    font-style: italic;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
}

.error-popup-rule::before {
    content: '📚 ';
}

/* ====================================================================
   RESPONSIVE ADJUSTMENTS
   ==================================================================== */

@media (max-width: 768px) {
    .cefr-score-dashboard {
        grid-template-columns: 1fr;
    }

    .cefr-score-card.overall {
        grid-column: span 1;
    }

    .tab-btn {
        font-size: 13px;
        padding: 10px 16px;
        max-width: none;
    }

    .error-popup {
        max-width: 90vw;
        min-width: 200px;
    }
}
