/* ============================================
   WORDSCOUT - Fixed 720x1080 with auto-scale
   ============================================ */

* { box-sizing: border-box; }

:root {
    --primary-color: #3498db;
    --primary-hover: #2980b9;
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-color);
}

/* The wrapper acts as the visible viewport. The panel scales within it. */
#wordscout-app {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* THE FIXED 720x1080 CONTAINER */
.wordscout-panel {
    background: var(--card-bg);
    width: 720px;
    height: 1080px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(0,0,0,0.15);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    /* The scale value is set inline by JS based on viewport size */
    transform-origin: center center;
}

/* HEADER */
header {
    text-align: center;
    padding: 25px 30px 10px;
    flex-shrink: 0;
}

header h1 {
    margin: 0;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.subtitle {
    margin: 10px 0 0;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.status-badge {
    font-size: 0.8rem;
    padding: 6px 14px;
    border-radius: 9999px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-ready { background: #ecfdf5; color: var(--success-color); border: 1px solid #d1fae5; }
.status-loading { background: #fffbeb; color: var(--warning-color); border: 1px solid #fef3c7; }
.status-error { background: #fef2f2; color: var(--error-color); border: 1px solid #fee2e2; }

/* SEARCH FORM */
.ws-form {
    padding: 25px 40px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.ws-field label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 10px;
    display: block;
    letter-spacing: 0.05em;
}

.ws-field input, .ws-field select {
    padding: 14px 18px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1.1rem;
    color: var(--text-color);
    background-color: #fff;
    width: 100%;
    height: 60px;
}

#ws-dictionary {
    background-color: #f8fafc;
    border-color: var(--primary-color);
    border-width: 2px;
    font-weight: 600;
    flex-grow: 1;
}

.dictionary-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.dict-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.2s;
    height: 60px;
    min-width: 70px;
    color: var(--text-muted);
}

.icon-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0f9ff;
}

.icon-btn span {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    margin-top: 4px;
}

.local-dicts-manager {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 15px;
}

.local-dict-item {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    max-width: 200px;
}

.local-dict-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 8px;
    color: var(--text-color);
}

.local-dict-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.local-dict-delete:hover {
    color: var(--error-color);
}

.icon-btn.delete-btn {
    border-color: rgba(239, 68, 68, 0.2);
}

.icon-btn.delete-btn:hover {
    border-color: var(--error-color);
    color: var(--error-color);
    background: #fef2f2;
}

.main-field input {
    height: 80px;
    font-size: 1.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.ws-grid {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.filter-group {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    height: 60px;
    width: 100%;
}

.filter-group select {
    width: 180px;
    flex-shrink: 0;
    border: none;
    background: #f8fafc;
    font-size: 1.1rem;
    border-radius: 0;
    padding-left: 15px;
}

.filter-group .input-wrapper {
    flex-grow: 1;
}

.filter-group input {
    border: none;
    border-left: 1px solid var(--border-color);
    border-radius: 0;
    height: 100%;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-wrapper input {
    padding-right: 45px !important;
}

.clear-btn-inline {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #a0aec0;
    cursor: pointer;
}

/* DIAL */
.dial-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dial-toggle-group {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 10px;
}

.toggle-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
}

.toggle-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.dial-wrapper {
    position: relative;
    height: 60px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.dial-glass {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 65px;
    height: 100%;
    border-left: 2px solid var(--primary-color);
    border-right: 2px solid var(--primary-color);
    z-index: 10;
    pointer-events: none;
    background: rgba(52, 152, 219, 0.05);
}

.dial-scroller {
    display: flex;
    height: 100%;
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}
.dial-scroller::-webkit-scrollbar { display: none; }

.dial-num {
    flex: 0 0 65px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-muted);
    scroll-snap-align: center;
}

.dial-num.selected {
    color: var(--primary-color);
    font-size: 1.9rem;
}

.dial-spacer { flex: 0 0 calc(50% - 32.5px); }

/* RESULTS */
.ws-results-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f8fafc;
}

.results-header {
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.results-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
}

.sort-control {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sort-control label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
}

.sort-control select {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.95rem;
    height: 44px;
    width: auto;
    border: 1px solid var(--border-color);
    background: #fff;
}

.results-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.word-item {
    background: #fff;
    padding: 18px 24px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border-color);
    cursor: pointer;
}

.word-main {
    display: flex;
    align-items: center;
    gap: 16px;
}

.word-text {
    font-size: 1.4rem;
    font-weight: 800;
}

.word-len {
    font-size: 0.9rem;
    background: #f1f5f9;
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bingo-badge {
    background: linear-gradient(135deg, #ffd700, #ffa500);
    color: #000;
    font-size: 0.7rem;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 4px;
}

.word-scores {
    display: flex;
    gap: 12px;
}

.score-tag {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 55px;
    padding: 6px 8px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid var(--border-color);
}

.score-tag .label { font-size: 0.7rem; font-weight: 800; color: var(--text-muted); }
.score-tag .val { font-size: 1.15rem; font-weight: 800; }
.score-tag.scrabble { border-top: 3px solid #f97316; }
.score-tag.wwf { border-top: 3px solid #8b5cf6; }

.empty-state {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 40px;
    color: var(--text-muted);
    font-style: italic;
    font-size: 1.2rem;
}

/* MODAL */
.ws-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
}

.ws-modal-content {
    background-color: #fff;
    margin: 10vh auto;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    border-radius: 24px;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

.ws-modal-close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
}

.header-main {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 100%;
}

.info-btn {
    position: absolute;
    right: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.info-btn:hover {
    color: var(--primary-color);
    background: rgba(52, 152, 219, 0.1);
}

.docs-view {
    text-align: left;
}

.docs-header h3 { font-size: 1.8rem; margin: 0; }
.docs-header p { color: var(--text-muted); margin: 5px 0 20px; font-weight: 600; }

.docs-body section { margin-bottom: 30px; }
.docs-body h4 { margin: 0 0 15px; color: var(--primary-color); text-transform: uppercase; font-size: 1.1rem; letter-spacing: 0.05em; border-bottom: 2px solid rgba(52, 152, 219, 0.1); padding-bottom: 8px; }

.doc-sub {
    margin-top: 20px;
}

.doc-sub h5 {
    margin: 0 0 8px;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-color);
}

.doc-sub p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 10px;
}
.docs-body ul { padding-left: 20px; margin: 0; }
.docs-body li { margin-bottom: 8px; line-height: 1.4; font-size: 0.95rem; }

.docs-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 15px;
    border-radius: 12px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.5;
    margin-top: 10px;
}

.confirm-view {
    text-align: center;
    padding: 20px 10px;
}

.confirm-view h3 {
    margin: 0 0 15px;
    color: var(--error-color);
}

.confirm-view p {
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 25px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.ws-btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.ws-btn-danger {
    background: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

.ws-btn-danger:hover {
    background: #dc2626;
}

.ws-btn:hover:not(.ws-btn-danger) {
    background: #f1f5f9;
    border-color: var(--primary-color);
}

.def-header h3 { font-size: 2rem; margin: 0; }
.def-phonetic { color: var(--primary-color); font-size: 1rem; }
.def-meaning { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-color); }
.def-part { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; color: var(--primary-color); background: rgba(52, 152, 219, 0.1); padding: 4px 12px; border-radius: 6px; margin-bottom: 10px; display: inline-block; }
.def-meaning ol { margin: 10px 0; padding-left: 20px; line-height: 1.6; }
