/* ── Light theme (default fallback) ── */
:root {
    --bg:              #f8fafc;
    --surface:         #ffffff;
    --surface-alt:     #f1f5f9;
    --border:          #e2e8f0;
    --text:            #1e293b;
    --text-muted:      #6b7280;
    --primary:         #2563eb;
    --primary-hover:   #1d4ed8;
    --primary-ring:    rgba(37, 99, 235, 0.15);
    --error:           #dc3545;
    --error-bg:        #fef2f2;
    --error-border:    #fca5a5;
    --shadow:          rgba(0, 0, 0, 0.08);
    --shadow-lg:       rgba(0, 0, 0, 0.12);
    --btn-bg:          #2DC659;
    --btn-bg-hover:    #26b04e;
    --btn-color:       #0d3320;
    --btn-shimmer:     rgba(255,255,255,0.18);
    --btn-loading-color: rgba(13,51,32,0.8);
}

/* ── Dark theme ── */
[data-theme="dark"] {
    --bg:              #111111;
    --surface:         #1c1c1c;
    --surface-alt:     #282828;
    --border:          #333333;
    --text:            #eeeeee;
    --text-muted:      #888888;
    --primary:         #3b82f6;
    --primary-hover:   #2563eb;
    --primary-ring:    rgba(59, 130, 246, 0.2);
    --error:           #f87171;
    --error-bg:        #1a0a0a;
    --error-border:    #7f1d1d;
    --shadow:          rgba(0, 0, 0, 0.4);
    --shadow-lg:       rgba(0, 0, 0, 0.6);
    --btn-bg:          #2DC659;
    --btn-bg-hover:    #26b04e;
    --btn-color:       #0d3320;
    --btn-shimmer:     rgba(255,255,255,0.18);
    --btn-loading-color: rgba(13,51,32,0.8);
}

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    text-align: center;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* ── Theme toggle button ── */
#theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    min-width: unset;
    padding: 0;
    gap: 0;
    font-weight: 400;
    letter-spacing: 0;
    white-space: normal;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px var(--shadow);
    color: var(--text);
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

#theme-toggle:hover {
    background-color: var(--surface-alt);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

#theme-toggle .material-symbols-outlined {
    font-size: 1.25rem;
    opacity: 1;
}

/* ── Container ── */
.container {
    max-width: 800px;
    width: 90%;
    margin: 2rem auto;
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow);
    min-height: 500px;
    display: flex;
    flex-direction: column;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.content-area {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* ── Textarea ── */
textarea {
    width: 100%;
    min-height: 180px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    resize: vertical;
    box-sizing: border-box;
    line-height: 1.4;
    margin-bottom: 0.25rem;
    background-color: var(--surface);
    color: var(--text);
    box-shadow: 0 1px 3px var(--shadow);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

textarea::placeholder {
    color: var(--text-muted);
}

textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
    outline: none;
}

/* ── Lookup button ── */
.button-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

button {
    padding: 11px 28px;
    font-size: 15px;
    min-width: 120px;
    border: none;
    border-radius: 8px;
    background: var(--btn-bg);
    color: var(--btn-color);
    font-weight: 600;
    letter-spacing: 0.01em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px var(--shadow);
}

button.loading {
    cursor: not-allowed;
    background: var(--btn-bg);
    opacity: 0.8;
}

button.loading .material-symbols-outlined {
    animation: spin 1.5s linear infinite;
}

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

button.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        110deg,
        transparent 0%,
        var(--btn-shimmer) 40%,
        var(--btn-shimmer) 60%,
        transparent 100%
    );
    transform: translateX(-100%);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    100% { transform: translateX(100%); }
}

button:hover:not(:disabled):not(.loading) {
    background: var(--btn-bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px var(--shadow-lg);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px var(--shadow);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

button:focus,
textarea:focus,
.material-symbols-outlined:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

#theme-toggle:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ── Results ── */
.hidden {
    display: none;
}

.results {
    text-align: left;
    margin-top: auto;
    padding: 20px;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    height: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease,
                background-color 0.2s ease, border-color 0.2s ease;
}

.results:not(.hidden) {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.results.hidden {
    display: block;
    height: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
    border: none;
}

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

.results-actions {
    display: flex;
}

.results-actions .material-symbols-outlined {
    margin-left: 15px;
    color: var(--text-muted);
}

.results-actions .material-symbols-outlined:hover {
    color: var(--text);
}

.results-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.results-count {
    color: var(--text-muted);
    font-size: 14px;
    padding: 2px 8px;
    background: var(--border);
    border-radius: 12px;
}

.operator-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 0 6px;
}

.operator-tag {
    font-size: 13px;
    padding: 3px 10px;
    background: var(--surface-alt);
    color: var(--text);
    border-radius: 12px;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.operator-tag:hover {
    background: var(--border);
}

.operator-tag.active {
    background: var(--primary);
    color: #fff;
}

.operator-count {
    font-weight: 600;
}

.operator-tag.active .operator-count {
    color: #fff;
}

.filter-hint {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    padding: 6px 0 0;
    margin: 0;
}

.results ul {
    list-style: none;
    padding: 0;
    min-height: 50px;
}

.results li {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s ease;
    border-radius: 4px;
}

.results li:last-child {
    border-bottom: none;
}

.results li:hover {
    background-color: var(--surface);
}

/* ── Icons ── */
.material-symbols-outlined {
    font-variation-settings:
        'FILL' 0,
        'wght' 400,
        'GRAD' 0,
        'opsz' 48;
    display: inline-block;
    vertical-align: middle;
    transition: opacity 0.2s ease, color 0.2s ease;
    opacity: 0.8;
    cursor: pointer;
}

.material-symbols-outlined:hover {
    opacity: 1;
}

/* ── Error message ── */
.error-message {
    color: var(--error);
    background-color: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: 6px;
    padding: 12px 16px;
    margin: 10px 0;
    animation: fadeIn 0.3s ease-in;
    text-align: left;
    line-height: 1.5;
    display: inline-block;
    min-width: 200px;
    max-width: 100%;
    box-sizing: border-box;
}

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

/* ── Heading & flag ── */
h2 {
    margin-bottom: 0.1rem;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
}

.h2-text {
    background: linear-gradient(135deg, #1a56db, #3b82f6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.flag-svg {
    width: 1.6em;
    height: auto;
    vertical-align: middle;
    margin-right: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

/* ── Body text ── */
p {
    margin-bottom: 1rem;
    font-size: 18px;
    color: var(--text);
}

/* ── Import file label (secondary button) ── */
.import-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
    white-space: nowrap;
    user-select: none;
}

.import-label:hover {
    color: var(--text);
    border-color: var(--primary);
    background-color: var(--primary-ring);
}

.import-label .material-symbols-outlined {
    font-size: 18px;
    cursor: pointer;
}

textarea.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-ring);
    outline: none;
}

.keyboard-hint {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 0.25rem;
    opacity: 0.8;
}

.loading-text {
    font-size: 14px;
    color: var(--btn-loading-color);
    white-space: nowrap;
}

/* ── Results h3 ── */
.results h3 {
    margin: 0;
    color: var(--text);
}

/* ── Dark mode: no blue gradient on title ── */
[data-theme="dark"] .h2-text {
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
    color: var(--text);
}
