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

:root {
    --color-primary: #d97757;
    --color-secondary: #6b6b6b;
    --color-accent: #da7756;
    --color-background: #fcf7f1;
    --color-surface: #ffffff;
    --color-text: #383838;
    --color-muted: #9e9e9e;
    --color-success: #4d8b55;
    --color-warning: #d49e2a;
    --color-error: #d15648;
    --color-info: #4a8bb3;
    --font-heading: "Merriweather", serif;
    --font-body: "DM Sans", sans-serif;
    --radius: 1rem;
    --border-width: 1px;
}

body {
    font-family: var(--font-body);
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-background);
    min-height: 100vh;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: var(--color-text);
}

.header-content h1 {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--color-primary);
}

.header-content h1 i {
    margin-right: 15px;
    color: var(--color-accent);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Main content */
.main-content {
    flex: 1;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
    border: var(--border-width) solid rgba(0, 0, 0, 0.05);
}

/* Recent results section */
.recent-results-section {
    padding: 30px 40px;
    border-bottom: 2px solid #f0f0f0;
}

.recent-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    color: var(--color-text);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.recent-title i {
    color: var(--color-primary);
}

.recent-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.result-card {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.result-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-color: var(--color-primary);
}

.result-card-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background: #f8f9fa;
}

.result-card-content {
    padding: 12px 15px;
}

.result-card-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.result-card-count {
    font-size: 0.9rem;
    color: var(--color-primary);
    font-weight: 600;
}

.result-card-count i {
    margin-right: 5px;
}

.result-card-time {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.empty-recent {
    text-align: center;
    padding: 30px;
    color: var(--color-muted);
}

.empty-recent i {
    font-size: 2rem;
    margin-bottom: 10px;
    opacity: 0.5;
}

/* Upload section */
.upload-section {
    padding: 60px 40px;
    text-align: center;
}

.upload-area {
    border: 3px dashed #ddd;
    border-radius: 15px;
    padding: 60px 40px;
    transition: all 0.3s ease;
    cursor: pointer;
    background: #fafafa;
}

.upload-area:hover {
    border-color: var(--color-primary);
    background: #fff;
    transform: translateY(-2px);
}

.upload-area.dragover {
    border-color: var(--color-primary);
    background: #fff;
    transform: scale(1.02);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.upload-icon {
    font-size: 4rem;
    color: var(--color-primary);
    margin-bottom: 20px;
}

.upload-content h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--color-text);
    margin-bottom: 10px;
}

.upload-hint {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 30px;
}

.upload-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.upload-btn:hover {
    transform: translateY(-2px);
    background: var(--color-accent);
    box-shadow: 0 4px 12px rgba(217, 119, 87, 0.3);
}

.upload-progress {
    margin-top: 30px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 15px;
}

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

.progress-text {
    color: #666;
    font-size: 0.9rem;
}

/* Processing section */
.processing-section {
    padding: 80px 40px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.processing-content {
    max-width: 500px;
}

.processing-animation {
    margin-bottom: 40px;
}

.ai-brain {
    font-size: 4rem;
    color: var(--color-primary);
    margin-bottom: 30px;
    animation: pulse 2s infinite;
}

.processing-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 40px;
}

.processing-dots span {
    width: 12px;
    height: 12px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.processing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.processing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.processing-content h3 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--color-text);
    margin-bottom: 15px;
}

.processing-text {
    color: #666;
    margin-bottom: 40px;
    font-size: 1.1rem;
}

.processing-steps {
    display: flex;
    justify-content: space-around;
    gap: 20px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #ccc;
    transition: color 0.3s ease;
}

.step i {
    font-size: 1.5rem;
}

.step.active {
    color: var(--color-primary);
}

.step.active i {
    animation: pulse 1s infinite;
}

/* Results section */
.results-section {
    padding: 40px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.results-header h3 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--color-text);
}

.results-actions {
    display: flex;
    gap: 15px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.results-container {
    display: flex;
    justify-content: center;
    align-items: start;
}

.image-container {
    position: relative;
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e9ecef;
    max-width: 100%;
    width: 100%;
}

.result-image {
    width: 100%;
    height: auto;
    display: block;
}

.annotation-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.annotation-point {
    fill: var(--color-primary);
    stroke: white;
    stroke-width: 2;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s ease;
}

.annotation-point:hover {
    fill: var(--color-accent);
    r: 8;
}

.image-label {
    position: absolute;
    background: rgba(255, 255, 255, 0.95);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
    cursor: pointer;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    border: 1.5px solid var(--color-primary);
    transition: all 0.2s ease;
    z-index: 10;
}

.image-label:hover {
    background: var(--color-primary);
    color: white;
    z-index: 20;
    transform: translate(-50%, -50%) scale(1.05);
}

.image-label .en {
    font-weight: 600;
    display: block;
    line-height: 1.2;
}

.image-label .cn {
    font-size: 0.7rem;
    opacity: 0.8;
    color: var(--color-secondary);
}

.image-label:hover .cn {
    color: rgba(255, 255, 255, 0.9);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 25px 30px;
    border-bottom: 1px solid #e9ecef;
    background: var(--color-background);
    color: var(--color-text);
}

.modal-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--color-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--color-text);
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(80vh - 100px);
}

.word-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.word-header h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--color-text);
    margin: 0;
}

.play-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.play-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(217, 119, 87, 0.3);
}

.chinese-name {
    font-size: 1.4rem;
    color: var(--color-primary);
    font-weight: 500;
    margin-bottom: 25px;
}

.sentences,
.explanations {
    margin-bottom: 25px;
}

.sentence,
.explanation {
    margin-bottom: 15px;
}

.sentence h4,
.explanation h4 {
    color: var(--color-text);
    margin-bottom: 8px;
    font-size: 1rem;
    font-weight: 600;
}

.sentence p,
.explanation p {
    color: var(--color-secondary);
    line-height: 1.6;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
}

.loading-spinner {
    font-size: 3rem;
    color: white;
}

/* Error toast */
.error-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #dc3545;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(220, 53, 69, 0.3);
    z-index: 3000;
    animation: slideInRight 0.3s ease;
}

.error-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Animations */
@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .header-content h1 {
        font-size: 2rem;
    }

    .upload-section {
        padding: 40px 20px;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .results-container {
        padding: 0 10px;
    }

    .results-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .results-actions {
        justify-content: center;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .modal-body {
        padding: 20px;
    }

    .word-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .upload-content h3 {
        font-size: 1.2rem;
    }

    .upload-icon {
        font-size: 3rem;
    }

    .processing-content h3 {
        font-size: 1.5rem;
    }

    .processing-steps {
        flex-direction: column;
        gap: 15px;
    }
}

/* Scrollbar styling */
.annotations-list::-webkit-scrollbar {
    width: 6px;
}

.annotations-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

.annotations-list::-webkit-scrollbar-thumb:hover {
    background: #999;
}