/* ── Reset & Globals ── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #1a1b1c;
    --bg-card: #252627;
    --bg-elevated: #2d2e30;
    --text-primary: #f2ece9;
    --text-secondary: rgba(242, 236, 233, 0.6);
    --text-muted: rgba(242, 236, 233, 0.35);
    --accent: #f07727;
    --accent-hover: #ff8a3d;
    --accent-glow: rgba(240, 119, 39, 0.4);
    --success: #2ecc71;
    --border: rgba(242, 236, 233, 0.08);
    --border-hover: rgba(240, 119, 39, 0.5);
    --sidebar-width: 280px;
    --header-height: 56px;
}

html,
body {
    height: 100%;
    font-family: 'Roboto', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
}

/* ── Header ── */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.file-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Buttons ── */
.btn-primary {
    padding: 8px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition:
        background 0.15s,
        opacity 0.15s;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: default;
}

.btn-nav {
    padding: 6px 14px;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: border-color 0.15s;
}

.btn-nav:hover:not(:disabled) {
    border-color: var(--border-hover);
}

.btn-nav:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ── Layout ── */
#app-layout {
    display: flex;
    height: calc(100% - var(--header-height));
}

/* ── Sidebar ── */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-label {
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* ── Drop Zone ── */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 16px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
    cursor: pointer;
    transition:
        border-color 0.2s,
        background 0.2s;
    position: relative;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(240, 119, 39, 0.05);
}

.drop-zone input[type='file'] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* ── Fields ── */
.field-row {
    display: flex;
    gap: 10px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.field label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.field input[type='number'],
.field input[type='color'] {
    padding: 6px 8px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    width: 100%;
    transition: border-color 0.15s;
}

.field input[type='number']:focus {
    outline: none;
    border-color: var(--accent);
}

.field input[type='color'] {
    height: 32px;
    padding: 2px 4px;
    cursor: pointer;
}

.checkbox-field {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.checkbox-field input[type='checkbox'] {
    accent-color: var(--accent);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.checkbox-field label {
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* ── Groups List ── */
.groups-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.empty-state {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 12px;
}

.group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.group-item:hover,
.group-item.active {
    border-color: var(--accent);
}

.group-item.active {
    background: rgba(240, 119, 39, 0.08);
}

.group-size {
    font-size: 0.85rem;
    font-weight: 500;
}

.group-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 10px;
}

/* ── Preview Area ── */
#preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.preview-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

#preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sheet-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

#sheet-indicator {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 100px;
    text-align: center;
}

#svg-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 24px;
    background: var(--bg-dark);
}

#preview-svg {
    background: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    max-width: 100%;
    max-height: 100%;
}

#sheet-info {
    padding: 8px 16px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ── Scrollbar ── */
#sidebar::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(242, 236, 233, 0.15);
}

/* ── Welcome Dialog ── */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.overlay.hidden {
    display: none;
}

.dialog {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    max-width: 440px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dialog h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
}

.dialog p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.dialog p strong {
    color: var(--accent);
    font-weight: 500;
}

.dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

/* ── AI Ready Badge ── */
.ai-badge {
    background: transparent;
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    transition: all 0.2s;
}

.ai-badge:hover {
    background: var(--accent);
    color: #fff;
}

.ai-badge svg {
    display: block;
}

/* ── AI Accessible Modal ── */
#ai-accessible-overlay {
    z-index: 1001;
}

.ai-accessible-modal {
    background: var(--bg-card);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 20px 25px;
    max-width: 380px;
    width: 90%;
    color: var(--text-primary);
    box-shadow: 0 0 40px var(--accent-glow);
}

.ai-accessible-header {
    text-align: center;
    margin-bottom: 12px;
}

.ai-robot-icon {
    margin-bottom: 6px;
}

.ai-robot-icon svg {
    width: 32px;
    height: 32px;
}

.ai-accessible-header h2 {
    color: var(--accent);
    margin: 0;
    font-size: 1.1rem;
}

.ai-accessible-content {
    background: var(--bg-elevated);
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.ai-intro {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
    text-align: center;
}

.ai-intro strong {
    color: var(--text-primary);
}

.ai-how-to {
    margin-bottom: 0;
}

.ai-accessible-content h3 {
    color: var(--accent);
    font-size: 0.7rem;
    margin: 0 0 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.ai-accessible-content ol {
    margin: 0;
    padding-left: 18px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.ai-accessible-content li {
    margin-bottom: 4px;
    line-height: 1.3;
}

.ai-example {
    background: var(--bg-dark);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    color: #4fc3f7;
}

.ai-accessible-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-dont-show {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
}

.ai-dont-show input {
    cursor: pointer;
    width: 14px;
    height: 14px;
    accent-color: var(--accent);
}

.ai-got-it-btn {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-got-it-btn:hover {
    background: var(--accent-hover);
}
