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

:root {
    /* Color Palette */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #16a34a;
    --success-bg: #dcfce7;
    --error-color: #dc2626;
    --error-bg: #fee2e2;
    --warning-color: #0369a1;
    --warning-bg: #dbeafe;
    --neutral-50: #fafafa;
    --neutral-100: #f4f4f5;
    --neutral-200: #e4e4e7;
    --neutral-300: #d4d4d8;
    --neutral-600: #52525b;
    --neutral-800: #27272a;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    
    /* Borders and Shadows */
    --border-radius: 0.5rem;
    --border-radius-lg: 0.75rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Base Styles */
body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--neutral-800);
    background-color: var(--neutral-100);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 42rem;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Utility Classes */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Header */
.header {
    text-align: center;
    padding: var(--spacing-xl) 0 var(--spacing-lg);
}

.title {
    font-size: clamp(1.75rem, 5vw, 2.25rem);
    font-weight: 700;
    color: var(--neutral-800);
    margin-bottom: var(--spacing-sm);
}

.emoji {
    display: inline-block;
    margin-right: var(--spacing-sm);
}

.subtitle {
    font-size: var(--font-size-lg);
    color: var(--neutral-600);
}

/* API Status Banner */
.api-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    border-radius: var(--border-radius);
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: all 0.3s ease;
}

.api-status.online {
    background-color: var(--success-bg);
    color: var(--success-color);
}

.api-status.offline {
    background-color: var(--error-bg);
    color: var(--error-color);
}

.api-status.checking {
    background-color: var(--warning-bg);
    color: var(--warning-color);
}

/* Main Content */
.main-content {
    flex: 1;
}

/* Search Section */
.search-section {
    background: white;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-lg);
}

.search-wrapper {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.search-input {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-lg);
    border: 2px solid var(--neutral-200);
    border-radius: var(--border-radius);
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-button {
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: white;
    background-color: var(--primary-color);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-button:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.search-button:active {
    transform: translateY(0);
}

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

.search-hint {
    font-size: var(--font-size-sm);
    color: var(--neutral-600);
    text-align: center;
}

/* Results Section */
.results-section {
    margin-bottom: var(--spacing-lg);
}

.result-card {
    background: white;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    border-left: 4px solid;
    animation: slideIn 0.3s ease-out;
}

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

.result-card.correct {
    border-left-color: var(--success-color);
    background-color: #f0fdf4;
}

.result-card.correct .result-status {
    color: var(--success-color);
}

.result-card.correct .result-word {
    color: #15803d;
}

.result-card.correct .result-explanation {
    color: #166534;
}

.result-card.informal {
    border-left-color: var(--warning-color);
    background-color: #eff6ff;
}

.result-card.informal .result-status {
    color: var(--warning-color);
}

.result-card.informal .result-word {
    color: #0c4a6e;
}

.result-card.informal .result-explanation {
    color: #075985;
}

.result-card.not-found {
    border-left-color: var(--neutral-300);
}

.result-card.not-found .result-status {
    color: var(--neutral-800);
}

.result-card.not-found .result-explanation {
    color: var(--neutral-600);
}

.result-status {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.result-word {
    font-size: var(--font-size-xl);
    margin: var(--spacing-sm) 0;
    color: var(--neutral-800);
}

.result-explanation {
    color: var(--neutral-600);
    margin-top: var(--spacing-sm);
    line-height: 1.5;
}

/* History Section */
.history-section {
    background: white;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-lg);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.section-title {
    font-size: var(--font-size-xl);
    font-weight: 600;
}

.clear-button {
    background: none;
    border: none;
    color: var(--error-color);
    font-size: var(--font-size-sm);
    cursor: pointer;
    text-decoration: underline;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    background-color: var(--neutral-50);
    border-radius: var(--border-radius);
}

.history-word {
    font-weight: 500;
}

.history-time {
    font-size: var(--font-size-sm);
    color: var(--neutral-600);
}

.empty-state {
    text-align: center;
    color: var(--neutral-600);
    padding: var(--spacing-md);
}

/* Submit Section */
.submit-section {
    background: white;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: var(--spacing-lg);
}

.submit-summary {
    cursor: pointer;
    font-weight: 600;
    padding: var(--spacing-sm) 0;
    list-style: none;
}

.submit-summary::-webkit-details-marker {
    display: none;
}

.submit-summary::before {
    content: '▸ ';
    display: inline-block;
    transition: transform 0.2s;
}

.submit-details[open] .submit-summary::before {
    transform: rotate(90deg);
}

.submit-form {
    margin-top: var(--spacing-md);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-base);
    border: 1px solid var(--neutral-300);
    border-radius: var(--border-radius);
    font-family: inherit;
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

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

.submit-button {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-lg);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: white;
    background-color: var(--primary-color);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.submit-button:hover {
    background-color: var(--primary-hover);
}

.form-note {
    margin-top: var(--spacing-sm);
    font-size: var(--font-size-sm);
    color: var(--neutral-600);
    text-align: center;
}

/* Footer */
.footer {
    text-align: center;
    padding: var(--spacing-lg);
    color: var(--neutral-600);
    font-size: var(--font-size-sm);
}

/* Loading State */
.loading {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Mobile Responsive */
@media (max-width: 640px) {
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .search-wrapper {
        flex-direction: column;
    }
    
    .search-button {
        width: 100%;
    }
    
    .title {
        font-size: 1.75rem;
    }
    
    .search-section,
    .history-section,
    .submit-section {
        padding: var(--spacing-md);
    }
}

/* Dark Mode Support (if user prefers) */
@media (prefers-color-scheme: dark) {
    :root {
        --neutral-50: #18181b;
        --neutral-100: #27272a;
        --neutral-200: #3f3f46;
        --neutral-300: #52525b;
        --neutral-600: #a1a1aa;
        --neutral-800: #fafafa;
    }
    
    body {
        background-color: #09090b;
    }
    
    .search-section,
    .history-section,
    .submit-section,
    .result-card {
        background-color: var(--neutral-100);
    }
    
    .history-item {
        background-color: var(--neutral-50);
    }
    
    .search-input,
    .form-input,
    .form-textarea {
        background-color: var(--neutral-50);
        color: var(--neutral-800);
        border-color: var(--neutral-300);
    }
}