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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow: hidden;
}

.container {
    width: 100%;
    max-width: 900px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Chat Container */
.chat-container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 800px;
    overflow: hidden;
    flex: 1;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    text-align: center;
    border-radius: 16px 16px 0 0;
    position: relative;
}

.chat-header h1 {
    font-size: 28px;
    margin-bottom: 8px;
    font-weight: 600;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 400;
}

.header-buttons {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.settings-toggle,
.corrections-link {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.settings-toggle:hover,
.corrections-link:hover {
    background: rgba(255, 255, 255, 0.3);
}

.settings-toggle:hover {
    transform: rotate(90deg);
}

.corrections-link:hover {
    transform: scale(1.1);
}

/* Settings Info Box */
.settings-info {
    background: #f8f9fa;
    border-bottom: 1px solid #e1e8ed;
}

.settings-info-toggle {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.settings-info-toggle:hover {
    background: #e9ecef;
}

.info-icon {
    font-size: 16px;
}

.info-text {
    font-size: 13px;
    font-weight: 500;
    color: #495057;
}

.info-arrow {
    margin-left: auto;
    font-size: 10px;
    color: #6c757d;
    transition: transform 0.2s;
}

.settings-info.collapsed .info-arrow {
    transform: rotate(-90deg);
}

.settings-info-content {
    padding: 0 24px 12px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
}

.settings-info.collapsed .settings-info-content {
    max-height: 0;
    padding: 0 24px;
}

.info-item {
    display: flex;
    gap: 8px;
    font-size: 13px;
    align-items: baseline;
}

.info-label {
    color: #6c757d;
    font-weight: 500;
    white-space: nowrap;
}

.info-value {
    color: #495057;
    font-weight: 400;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    min-height: 0; /* Critical for flex shrinking */
    overflow-y: auto;
    padding: 24px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Markdown Styling within Messages */
.message-content p {
    margin: 0 0 12px 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1:first-child,
.message-content h2:first-child,
.message-content h3:first-child {
    margin-top: 0;
}

.message-content h1 { font-size: 1.8em; }
.message-content h2 { font-size: 1.5em; }
.message-content h3 { font-size: 1.3em; }
.message-content h4 { font-size: 1.1em; }

.message-content ul,
.message-content ol {
    margin: 8px 0 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 4px 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.message-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.message-content blockquote {
    border-left: 3px solid #667eea;
    margin: 12px 0;
    padding: 8px 16px;
    background: rgba(102, 126, 234, 0.05);
    font-style: italic;
}

.message-content a {
    color: #667eea;
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
}

.message-content th,
.message-content td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.message-content th {
    background: #f5f5f5;
    font-weight: 600;
}

.message-content hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 16px 0;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    color: #6c757d;
    padding: 40px 20px;
}

.welcome-message p {
    font-size: 18px;
    margin-bottom: 8px;
}

.welcome-subtitle {
    font-size: 20px;
    font-weight: 500;
    opacity: 0.9;
    margin-bottom: 12px;
}

.welcome-hint {
    font-size: 14px;
    opacity: 0.7;
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
}

.feature-highlight {
    background: linear-gradient(135deg, #f8f9ff 0%, #eff1ff 100%);
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 20px;
    margin-top: 24px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    text-align: left;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.1);
}

.feature-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.feature-text {
    flex: 1;
}

.feature-text strong {
    display: block;
    color: #667eea;
    font-size: 16px;
    margin-bottom: 8px;
    font-weight: 600;
}

.feature-text p {
    color: #555;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
}

/* Message Bubbles */
.message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-in;
}

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

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e1e8ed;
    border-bottom-left-radius: 4px;
}

.message-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 4px;
}

.message-content {
    white-space: pre-wrap;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 18px;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 70px;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    background: #90949c;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
    margin-right: 0;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Container */
.chat-input-container {
    background: white;
    border-top: 1px solid #e1e8ed;
    padding: 20px 24px;
}

.chat-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    border: 2px solid #e1e8ed;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.message-input:focus {
    outline: none;
    border-color: #667eea;
}

.message-input::-webkit-scrollbar {
    width: 6px;
}

.message-input::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.send-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-icon {
    font-size: 20px;
}

/* Error Message */
.error-message {
    background: #fee;
    color: #c33;
    padding: 12px 18px;
    border-radius: 12px;
    border: 1px solid #fcc;
    margin-bottom: 16px;
    text-align: center;
}

/* Settings Panel */
.settings-panel {
    background: #f8f9fa;
    border-bottom: 1px solid #e1e8ed;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out, padding 0.3s ease-in-out;
}

.settings-panel.open {
    max-height: 450px;
    padding: 24px;
    overflow-y: auto;
}

.settings-panel h3 {
    color: #333;
    font-size: 18px;
    margin-bottom: 20px;
    font-weight: 600;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 20px;
}

.settings-column {
    display: flex;
    flex-direction: column;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    color: #495057;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 8px;
}

.setting-input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.setting-input:focus {
    outline: none;
    border-color: #667eea;
}

.setting-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e1e8ed;
    outline: none;
    -webkit-appearance: none;
}

.setting-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    transition: transform 0.2s;
}

.setting-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.setting-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    transition: transform 0.2s;
}

.setting-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.setting-help {
    font-size: 12px;
    color: #6c757d;
    margin-top: 6px;
    line-height: 1.4;
}

.custom-prompt {
    margin-top: 10px;
    resize: vertical;
    min-height: 60px;
}

.reset-button {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 10px;
}

.reset-button:hover {
    background: #5a6268;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 0;
        min-height: 100vh;
        min-height: calc(var(--vh, 1vh) * 100);
        overflow: hidden;
        position: relative;
        width: 100%;
    }

    /* When keyboard is open, adjust layout */
    body.keyboard-open {
        height: 100vh;
        height: calc(var(--vh, 1vh) * 100);
    }

    .container {
        min-height: 100vh;
        min-height: calc(var(--vh, 1vh) * 100);
        max-width: 100%;
        display: flex;
        flex-direction: column;
    }

    .chat-container {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-height: 0;
        border-radius: 0;
    }

    .chat-header {
        border-radius: 0;
        padding: 16px;
        flex-shrink: 0;
    }

    .chat-header h1 {
        font-size: 22px;
        margin-bottom: 4px;
    }

    .settings-toggle {
        top: 16px;
        right: 16px;
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .chat-messages {
        padding: 12px;
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        overscroll-behavior: contain; /* Prevent pull-to-refresh interference */
    }

    /* When keyboard is open, ensure messages area is scrollable */
    body.keyboard-open .chat-messages {
        flex: 1;
        overflow-y: auto;
    }

    .message-bubble {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 15px;
    }

    .chat-input-container {
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        flex-shrink: 0;
        background: white;
        border-top: 1px solid #e1e8ed;
        position: relative;
        margin-bottom: 0;
        z-index: 100;
    }

    /* When keyboard is open, make input more accessible */
    body.keyboard-open .chat-input-container {
        position: relative;
        margin-bottom: 0;
    }

    .message-input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px 16px;
        touch-action: manipulation; /* Better touch response */
    }

    .send-button {
        width: 44px;
        height: 44px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .settings-panel {
        flex-shrink: 0;
    }

    .settings-panel.open {
        max-height: 60vh;
        padding: 16px;
    }

    /* Hide settings when keyboard is open to maximize chat space */
    body.keyboard-open .settings-panel.open {
        max-height: 0;
        padding: 0;
        overflow: hidden;
    }

    /* Visual feedback: slightly highlight input when keyboard is active */
    body.keyboard-open .message-input:focus {
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
    }

    .setting-group {
        margin-bottom: 16px;
    }

    .settings-info-content {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .info-item {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 12px;
    }

    .chat-header h1 {
        font-size: 18px;
    }

    .subtitle {
        font-size: 11px;
    }

    .settings-toggle {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .chat-messages {
        padding: 10px;
    }

    .message-bubble {
        max-width: 90%;
        font-size: 14px;
        padding: 8px 12px;
    }

    .welcome-message {
        padding: 30px 16px;
    }

    .welcome-message p {
        font-size: 16px;
    }

    .welcome-subtitle {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .welcome-hint {
        font-size: 13px;
    }

    .chat-input-container {
        padding: 10px;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    }

    .chat-form {
        gap: 8px;
    }

    .send-button {
        width: 40px;
        height: 40px;
    }

    .send-icon {
        font-size: 16px;
    }
}

/* ==================== Correction Feature Styles ==================== */

/* Context Menu */
#correctionContextMenu {
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    min-width: 150px;
    overflow: hidden;
}

.context-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background-color: #f0f0f0;
}

/* Correction Modal */
#correctionModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.close-modal {
    font-size: 28px;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-modal:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.original-text {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    border: 1px solid #e9ecef;
}

#correctedTextInput {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}

#correctedTextInput:focus {
    outline: none;
    border-color: #667eea;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-cancel, .btn-save {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-cancel {
    background: #f1f3f5;
    color: #495057;
}

.btn-cancel:hover {
    background: #e9ecef;
}

.btn-save {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-save:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Corrected Text Highlighting */
.corrected-text {
    background: #d4edda;
    border-bottom: 2px solid #28a745;
    padding: 2px 4px;
    border-radius: 3px;
    position: relative;
    cursor: help;
    display: inline-block;
    color: #155724;
    font-weight: 500;
}

.correction-delete {
    display: inline-block;
    margin-left: 4px;
    color: #dc3545;
    font-weight: bold;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 4px;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.correction-delete:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

/* Success Message */
.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #28a745;
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    animation: slideInRight 0.3s ease-out;
}

/* Correction Hint */
.correction-hint {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 10001;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease-out;
    pointer-events: none;
}

.correction-hint.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.correction-hint-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 400px;
}

.correction-hint-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.correction-hint-text {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
}

.correction-hint-text strong {
    font-weight: 600;
}

.correction-hint-close {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.correction-hint-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

/* Mobile Responsive */
@media (max-width: 600px) {
    .modal-content {
        max-width: 100%;
        margin: 0 10px;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .success-message {
        top: 10px;
        right: 10px;
        left: 10px;
        font-size: 14px;
    }

    .feature-highlight {
        padding: 16px;
        margin-top: 20px;
        gap: 12px;
    }

    .feature-icon {
        font-size: 24px;
    }

    .feature-text strong {
        font-size: 15px;
    }

    .feature-text p {
        font-size: 13px;
    }

    .correction-hint {
        bottom: 60px;
        right: 10px;
        left: 10px;
    }

    .correction-hint-content {
        padding: 12px 16px;
        gap: 10px;
    }

    .correction-hint-icon {
        font-size: 20px;
    }

    .correction-hint-text {
        font-size: 13px;
    }

    .correction-hint-close {
        padding: 5px 12px;
        font-size: 12px;
    }
}

/* ==================== Corrections Review Page ==================== */

/* Override body styles for corrections page */
body:has(.corrections-container) {
    overflow-y: auto;
    height: auto;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.corrections-container {
    width: 100%;
    max-width: 900px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.corrections-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 32px;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.header-content .subtitle {
    font-size: 16px;
    opacity: 0.9;
    margin: 0;
}

.back-button {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s;
    font-weight: 500;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-5px);
}

/* Stats Cards */
.corrections-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    padding: 24px;
    padding-bottom: 0;
    background: #f8f9fa;
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    margin-bottom: 24px;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Filters */
.corrections-filters {
    background: #f8f9fa;
    padding: 24px;
    padding-top: 20px;
    padding-bottom: 20px;
    display: flex;
    gap: 16px;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
}

.sort-select {
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

/* Corrections List */
.corrections-list {
    min-height: 400px;
    padding: 24px;
    background: #f8f9fa;
    flex: 1;
    overflow-y: auto;
}

.correction-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
}

.correction-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.correction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.correction-date {
    color: #666;
    font-size: 14px;
}

.correction-id {
    color: #999;
    font-size: 12px;
    font-weight: 500;
}

.correction-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: start;
}

.correction-section {
    min-width: 0;
}

.correction-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.correction-text {
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.correction-text.original {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    color: #856404;
}

.correction-text.corrected {
    background: #d4edda;
    border-left: 3px solid #28a745;
    color: #155724;
}

.correction-arrow {
    display: flex;
    align-items: center;
    font-size: 24px;
    color: #667eea;
    font-weight: bold;
}

.correction-context {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.context-text {
    font-size: 14px;
    color: #333;
    margin-top: 4px;
}

.correction-footer {
    display: flex;
    justify-content: flex-end;
}

.btn-view-chat {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-view-chat:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* Loading, Empty, and Error States */
.loading-message,
.empty-state,
.error-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

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

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

.empty-icon,
.error-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.empty-state h3,
.error-state h3 {
    font-size: 24px;
    margin-bottom: 12px;
    color: #333;
}

.empty-state p,
.error-state p {
    font-size: 16px;
    margin-bottom: 24px;
    color: #666;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .corrections-header {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .header-content h1 {
        font-size: 24px;
    }

    .corrections-filters {
        flex-direction: column;
    }

    .correction-content {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .correction-arrow {
        transform: rotate(90deg);
        justify-content: center;
    }

    .stat-value {
        font-size: 28px;
    }
}
