/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-color: #f8fafc;
    --text-color: #1e293b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    
    /* Classification colors */
    --human-color: #4ade80;        /* Green */
    --likely-human-color: #86efac; /* Light green */
    --mixed-color: #fef08a;        /* Yellow */
    --likely-ai-color: #fca5a5;    /* Light red */
    --ai-color: #ef4444;           /* Red */
    --suspicious-color: #fef08a;   /* Kept for backward compatibility */
}

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

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

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 0;
    box-shadow: var(--shadow-lg);
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
}

/* Main Content */
.main-content {
    padding: 2rem 0;
}

/* Instructions */
.instructions {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.instructions .main-instruction {
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-size: 1.75rem;
    font-weight: 600;
}

.instructions .instruction-details {
    color: var(--text-color);
    font-size: 0.9rem;
    opacity: 0.8;
    margin: 0;
}

.instructions ul {
    margin-left: 1.5rem;
    margin-top: 1rem;
}

.instructions li {
    margin-bottom: 0.5rem;
}

/* Input Section */
.input-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.input-section h2 {
    color: var(--text-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-color);
}

.upload-area:hover,
.upload-area:focus {
    border-color: var(--primary-color);
    background: #eff6ff;
}

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

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

.upload-text {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--secondary-color);
}

/* Divider */
.divider {
    text-align: center;
    margin: 2rem 0;
    position: relative;
}

.divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: var(--border-color);
    z-index: 1;
}

.divider span {
    background: white;
    padding: 0 1rem;
    position: relative;
    z-index: 2;
    color: var(--secondary-color);
}

/* Text Input */
.text-input-container {
    margin-bottom: 1.5rem;
}

.input-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.text-input {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.char-count {
    text-align: right;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--secondary-color);
}

/* Buttons */
.btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
}

.btn-secondary:disabled {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Loading Section */
.loading-section {
    background: white;
    padding: 3rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    text-align: center;
    margin-bottom: 2rem;
}

.loader {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

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

/* Results Section */
.results-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.results-section h2 {
    color: var(--text-color);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Statistics */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-color);
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid;
}

.stat-card.human {
    border-left-color: var(--success-color);
}

.stat-card.suspicious {
    border-left-color: var(--warning-color);
}

.stat-card.ai {
    border-left-color: var(--danger-color);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-color);
    display: block;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-top: 0.5rem;
}

/* Legend */
.legend {
    background: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.legend h3 {
    font-size: 1rem;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

.legend-items {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-color {
    width: 30px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.legend-color.human {
    background: var(--human-color);
}

.legend-color.likely-human {
    background: var(--likely-human-color);
}

.legend-color.mixed {
    background: var(--mixed-color);
}

.legend-color.likely-ai {
    background: var(--likely-ai-color);
}

.legend-color.ai {
    background: var(--ai-color);
}

.legend-color.suspicious {
    background: var(--suspicious-color);
}

.legend-label {
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Analyzed Text */
.analyzed-text-container {
    margin-bottom: 2rem;
}

.analyzed-text-container h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.hint {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
    font-style: italic;
}

.analyzed-text {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    line-height: 2;
}

.sentence {
    display: inline;
    padding: 0.2rem 0.3rem;
    margin: 0.1rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sentence:hover {
    opacity: 0.8;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.sentence.human {
    background: var(--human-color);
}

.sentence.likely-human {
    background: var(--likely-human-color);
}

.sentence.mixed {
    background: var(--mixed-color);
}

.sentence.likely-ai {
    background: var(--likely-ai-color);
}

.sentence.ai {
    background: var(--ai-color);
}

.sentence.suspicious {
    background: var(--suspicious-color);
}

/* Export Buttons */
.export-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.export-buttons .btn {
    flex: 1;
    min-width: 200px;
}

/* Error Section */
.error-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border-left: 4px solid var(--danger-color);
}

.error-message {
    color: var(--danger-color);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

/* 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;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--shadow-lg);
    margin: 1rem;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 2rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--secondary-color);
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.modal-close:hover {
    color: var(--text-color);
}

#modalTitle {
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.modal-section {
    margin-bottom: 1.5rem;
}

.modal-section h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.modal-section p {
    margin-bottom: 0.5rem;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.9rem;
}

.feature-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--bg-color);
    border-radius: 4px;
}

/* Footer */
.footer {
    background: var(--text-color);
    color: white;
    padding: 2rem 0;
    text-align: center;
    margin-top: 3rem;
}

.footer p {
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .export-buttons {
        flex-direction: column;
    }
    
    .export-buttons .btn {
        width: 100%;
    }
    
    .legend-items {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .modal-content {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .feature-grid {
        grid-template-columns: 1fr;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
.upload-area:focus,
.text-input:focus,
.sentence:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
