/* Figma Variables Editor - Styles */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0;
    background: #f5f5f7;
    color: #1d1d1f;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 14px 20px;
    z-index: 10;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
    flex-shrink: 0;
}

h1 {
    font-size: 16px;
    margin: 0 0 12px;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.controls label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.controls label.checkbox {
    flex-direction: row;
    align-items: center;
    gap: 6px;
    text-transform: none;
    letter-spacing: 0;
    font-size: 13px;
    color: #1d1d1f;
}

.controls .spacer { flex: 1; }

select, input[type="text"], input[type="search"], input[type="number"] {
    padding: 6px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    min-width: 140px;
}

input[type="search"] { min-width: 200px; }

button {
    padding: 7px 16px;
    border: none;
    background: #0066cc;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
}

button:hover:not(:disabled) { background: #0052a3; }
button:disabled { background: #bbb; cursor: not-allowed; }

button.btn-secondary {
    background: #fff;
    color: #1d1d1f;
    border: 1px solid #d0d0d0;
}
button.btn-secondary:hover:not(:disabled) { background: #f0f0f0; }

#status {
    margin-top: 10px;
    font-size: 12px;
    color: #666;
    min-height: 16px;
}
#status.error { color: #cc0000; }

/* --- Layout: sidebar + main --- */

#layout {
    display: flex;
    flex: 1;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
}

#sidebar {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    padding: 10px 0 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-section { padding: 8px 0; }

.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 18px 8px;
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
}

.sidebar-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-section li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 18px;
    font-size: 13px;
    color: #1d1d1f;
    cursor: pointer;
    transition: background .08s;
}

.sidebar-section li:hover:not(.empty-hint) {
    background: #f5f5f7;
}

.sidebar-section li .item-count {
    color: #999;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.sidebar-section li .item-right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.collection-menu-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #999;
    padding: 1px 6px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    width: auto;
    font-weight: 700;
}

.collection-menu-btn:hover {
    background: #fff;
    border-color: #c0c0c0;
    color: #0066cc;
}

/* Collections: selected = bold */
#collection-list li.active {
    font-weight: 600;
}

/* Groups: selected = blue bg, blue text, bold */
#group-list li.active {
    background: #eaf2fb;
    color: #0052a3;
    font-weight: 600;
}
#group-list li.active .item-count {
    color: #0052a3;
}

/* Groups indentation */
#group-list li.depth-0 { padding-left: 18px; }
#group-list li.depth-1 { padding-left: 36px; }
#group-list li.depth-2 { padding-left: 54px; }
#group-list li.depth-3 { padding-left: 72px; }
#group-list li.depth-4 { padding-left: 90px; }

.sidebar-section li.empty-hint {
    color: #999;
    font-style: italic;
    cursor: default;
    padding: 10px 18px;
    justify-content: flex-start;
}

main {
    flex: 1;
    min-width: 0;
    padding: 0;
    overflow: auto;
    background: #fff;
}

.empty {
    padding: 60px 20px;
    text-align: center;
    color: #999;
    background: #fff;
    font-size: 14px;
}

/* --- Table --- */

table {
    border-collapse: collapse;
    width: 100%;
    background: white;
    table-layout: auto;
}

th, td {
    padding: 6px 16px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
    font-size: 13px;
    vertical-align: middle;
}

th {
    background: #fff;
    font-weight: 500;
    font-size: 13px;
    color: #6e6e73;
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid #e5e5ea;
}

.name-col {
    min-width: 240px;
    max-width: 340px;
    color: #1d1d1f;
    word-break: break-word;
}

.name-col .name-inner {
    display: flex;
    align-items: center;
    gap: 10px;
}

.name-col .var-name-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reviewed-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    border-radius: 999px;
    background: #e8f7ee;
    color: #2a8f5f;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

tr.var-row.reviewed {
    background: #f9fdfb;
}

.action-buttons {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity .1s;
}

tbody tr.var-row:hover .action-buttons {
    opacity: 1;
}

.translate-btn,
.review-btn {
    padding: 2px 8px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    letter-spacing: 0.3px;
    background: #fff;
    color: #6e6e73;
    border: 1px solid #d5d5da;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .1s, background .1s, color .1s, border-color .1s;
    flex-shrink: 0;
}

tbody tr.var-row:hover .translate-btn,
tbody tr.var-row:hover .review-btn {
    opacity: 1;
}

.translate-btn:hover,
.review-btn:hover {
    background: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

.translate-btn.loading,
.translate-btn:disabled,
.review-btn:disabled {
    opacity: 1;
    background: #eaf2fb;
    color: #0052a3;
    border-color: #b5d1ee;
    cursor: wait;
}

.type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 1px solid #d5d5da;
    border-radius: 4px;
    font-size: 10px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    color: #555;
    flex-shrink: 0;
    background: #fafafa;
    font-weight: 500;
}

.type-icon[data-type="COLOR"]  { background: #fff; padding: 2px; }
.type-icon .color-dot {
    width: 12px; height: 12px; border-radius: 50%;
    border: 1px solid rgba(0,0,0,.1);
}

/* --- Group separator (breadcrumb row) --- */

tr.group-separator td {
    padding: 18px 16px 6px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
}

tr.group-separator:first-child td { padding-top: 12px; }

.group-separator-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.bulk-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bulk-translate-btn,
.bulk-review-btn {
    padding: 3px 10px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
    letter-spacing: 0.3px;
    background: #fff;
    color: #6e6e73;
    border: 1px solid #d5d5da;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity .1s, background .1s, color .1s, border-color .1s;
    flex-shrink: 0;
}

tr.group-separator:hover .bulk-translate-btn,
tr.group-separator:hover .bulk-review-btn {
    opacity: 1;
}

.bulk-translate-btn:hover:not(:disabled),
.bulk-review-btn:hover:not(:disabled) {
    background: #0066cc;
    color: #fff;
    border-color: #0066cc;
}

.bulk-translate-btn.loading,
.bulk-translate-btn:disabled,
.bulk-review-btn.loading,
.bulk-review-btn:disabled {
    opacity: 1;
    background: #eaf2fb;
    color: #0052a3;
    border-color: #b5d1ee;
    cursor: wait;
}

.breadcrumb {
    font-size: 12px;
    color: #9a9a9e;
    font-weight: 400;
}
.breadcrumb strong {
    color: #1d1d1f;
    font-weight: 600;
}

/* --- Cell editors --- */

td .editor {
    width: 100%;
    border: 1px solid transparent;
    background: transparent;
    padding: 5px 7px;
    min-width: 100px;
    font-size: 13px;
    border-radius: 4px;
    font-family: inherit;
    color: #1d1d1f;
}
td .editor:hover  { border-color: #e0e0e0; }
td .editor:focus  { outline: none; border-color: #0066cc; background: #fff; box-shadow: 0 0 0 2px rgba(0,102,204,0.15); }
td .editor.edited { background: #fff8dc; border-color: #daa520; }
td .editor.missing:not(:focus) { color: #cc0000; font-style: italic; }

td.alias {
    color: #666;
    font-size: 12px;
    padding: 4px 10px;
}

.alias-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 100%;
    padding: 3px 8px 3px 5px;
    background: #f5f5f7;
    border: 1px solid #ececec;
    border-radius: 5px;
    font-size: 12px;
    color: #1d1d1f;
    line-height: 1.3;
    vertical-align: middle;
}

.alias-pill.unresolved {
    color: #999;
    font-style: italic;
    background: #fff;
    border-style: dashed;
}

.alias-pill .type-icon {
    width: 18px;
    height: 18px;
    font-size: 10px;
    background: #fff;
}

.alias-pill .alias-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

td.color-cell {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 4px;
}
td.color-cell .editor { min-width: 80px; font-family: monospace; text-transform: uppercase; }
.swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 1px solid #ccc;
    border-radius: 3px;
    flex-shrink: 0;
}

tbody tr.var-row:hover { background: #fafbfc; }

#dirty-count { font-weight: 400; opacity: 0.8; }

/* --- Settings modal --- */

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
}

.modal-dialog {
    position: relative;
    background: #fff;
    width: 92%;
    max-width: 640px;
    max-height: 85vh;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e5ea;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: #999;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 4px;
    width: auto;
}

.modal-close:hover { background: #f5f5f7; color: #1d1d1f; }

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-body h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin: 0 0 10px;
    font-weight: 600;
}

.modal-body h3:not(:first-child) { margin-top: 22px; }

.modal-body .hint {
    font-size: 12px;
    color: #666;
    margin: 0 0 12px;
    line-height: 1.5;
}

.modal-body .hint code {
    background: #f5f5f7;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
}

#files-list-settings {
    list-style: none;
    padding: 0;
    margin: 0;
}

#files-list-settings li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid #e5e5ea;
    border-radius: 6px;
    margin-bottom: 6px;
    background: #fafafa;
    gap: 10px;
}

#files-list-settings li.empty-hint {
    justify-content: center;
    color: #999;
    font-style: italic;
    background: #fff;
    border-style: dashed;
}

#files-list-settings li.empty-hint.error {
    color: #cc0000;
    border-color: #f5bcbc;
}

#files-list-settings .file-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

#files-list-settings .file-name {
    font-weight: 500;
    font-size: 13px;
    color: #1d1d1f;
}

#files-list-settings .file-key {
    font-size: 11px;
    color: #999;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delete-btn {
    background: #fff;
    color: #cc0000;
    border: 1px solid #e5b5b5;
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    flex-shrink: 0;
}

.delete-btn:hover {
    background: #fff0f0;
    border-color: #cc0000;
}

.field-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    margin: 10px 0 4px;
    font-weight: 500;
}

#new-file-url,
#new-file-name {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    box-sizing: border-box;
    min-width: 0;
}

#new-file-url:focus,
#new-file-name:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0,102,204,0.15);
}

.parsed-info {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 12px;
    color: #666;
}

.parsed-info code {
    background: #f5f5f7;
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
    color: #1d1d1f;
}

.add-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
}

.add-actions button {
    padding: 8px 20px;
}

#settings-status,
#modes-status {
    margin-top: 12px;
    min-height: 16px;
    font-size: 12px;
    color: #666;
}

#settings-status.error,
#modes-status.error {
    color: #cc0000;
}

/* --- Modes modal --- */

#modes-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#modes-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid #e5e5ea;
    border-radius: 6px;
    margin-bottom: 6px;
    background: #fafafa;
    gap: 10px;
}

#modes-list li.empty-hint {
    justify-content: center;
    color: #999;
    font-style: italic;
    background: #fff;
    border-style: dashed;
}

.mode-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.rename-btn {
    background: #fff;
    color: #1d1d1f;
    border: 1px solid #d0d0d0;
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
}

.rename-btn:hover {
    background: #f0f4f8;
    border-color: #0066cc;
    color: #0066cc;
}

.badge-default {
    display: inline-block;
    background: #e6f0fb;
    color: #0052a3;
    font-size: 10px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 3px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.add-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.add-row input {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 5px;
    font-size: 13px;
    font-family: inherit;
}

.add-row input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 2px rgba(0,102,204,0.15);
}

.add-row button {
    flex-shrink: 0;
}
