/* ============================================================
   CC LITE — TOKEN DESIGNER — Styles
   Standalone: no dependency on the full game's code.
   ============================================================ */

* { box-sizing: border-box; }

body {
    margin: 0; padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a2e; color: #eee;
    min-height: 100vh;
}

/* --- Auth gate --- */
.auth-gate {
    position: fixed; inset: 0; z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    background: #1a1a2e;
}
.auth-card {
    background: #16213e; border-radius: 16px; padding: 2.5rem;
    max-width: 380px; width: 90%; text-align: center;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.auth-card h1 { color: #e2c044; margin: 0 0 .25rem; font-size: 1.6rem; font-family: 'Georgia', serif; }
.auth-card .subtitle { color: #aaa; margin: 0 0 1.5rem; font-size: .9rem; }
.auth-input {
    width: 100%; padding: .6rem .8rem; border: 1px solid #333;
    border-radius: 8px; background: #0f1629; color: #eee;
    font-size: .95rem; margin-bottom: .8rem;
}
.auth-input:focus { outline: none; border-color: #e2c044; }
.auth-error { color: #f44; margin: 0 0 .8rem; font-size: .85rem; }
.btn-full { width: 100%; }

/* --- Buttons --- */
.btn {
    display: inline-block; padding: .55rem 1.2rem; border: none;
    border-radius: 8px; font-size: .85rem; cursor: pointer;
    font-weight: 600; transition: all .15s;
    text-decoration: none; text-align: center;
}
.btn-primary { background: #e2c044; color: #1a1a2e; }
.btn-primary:hover { background: #d4a82a; }
.btn-secondary { background: #3a506b; color: #eee; }
.btn-secondary:hover { background: #4a6a8b; }
.btn-danger { background: #c0392b; color: #fff; }
.btn-danger:hover { background: #e74c3c; }
.btn-sm { padding: .35rem .8rem; font-size: .78rem; }
.btn-xs { padding: .15rem .45rem; font-size: .72rem; border-radius: 5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* --- Header --- */
.app-header {
    background: #16213e; padding: .8rem 1.5rem;
    display: flex; align-items: center; gap: 1rem;
    border-bottom: 2px solid #e2c044;
    flex-wrap: wrap;
}
.app-header h1 {
    color: #e2c044; font-size: 1.25rem; margin: 0;
    font-family: 'Georgia', serif;
}
.app-header .header-actions {
    display: flex; gap: .5rem; margin-left: auto; align-items: center; flex-wrap: wrap;
}
.save-indicator { font-size: .75rem; font-weight: 600; transition: opacity .4s; }
.save-indicator.state-saved   { color: #27ae60; }
.save-indicator.state-saving  { color: #e2c044; }
.save-indicator.state-unsaved { color: #e2c044; }
.save-indicator.state-error   { color: #e74c3c; }

/* --- Views --- */
.view-panel { display: none; }
.view-panel.active { display: block; }

/* --- Token List --- */
.token-list { padding: 1.5rem; max-width: 1100px; margin: 0 auto; }
.token-list-header h2 { margin: 0 0 .3rem; color: #e2c044; }
.token-list-header .hint { color: #888; font-size: .8rem; margin: 0 0 .4rem; }
.token-summary { color: #e2c044; font-size: .82rem; font-weight: 600; margin: 0 0 1.2rem; }
.token-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}
.token-card {
    background: #16213e; border-radius: 12px; padding: 1rem 1.2rem;
    border: 1px solid #2a2a4a; cursor: pointer;
    transition: all .15s;
}
.token-card:hover { border-color: #e2c044; transform: translateY(-2px); }
.token-card-top { display: flex; gap: .9rem; align-items: center; }
.token-card-sides { display: flex; gap: .5rem; flex: 0 0 auto; }
.token-card-info { min-width: 0; }
.token-card h3 { margin: 0 0 .2rem; color: #eee; font-size: 1rem; }
.token-card .token-faction { font-size: .75rem; font-weight: 600; }
.token-card .token-meta { color: #888; font-size: .76rem; margin-top: .15rem; }
.token-card .token-notes {
    color: #99a; font-size: .76rem; margin-top: .5rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.token-card .token-actions { margin-top: .7rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.token-grid .empty-msg { color: #888; grid-column: 1/-1; text-align: center; padding: 2rem 0; }

/* --- Token circles (shared by list + editor preview) --- */
.token-circle {
    border-radius: 50%;
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
    box-shadow: 0 2px 6px rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
    /* size, background, border set inline */
}
.token-circle img {
    position: absolute; inset: 5%;
    width: 90%; height: 90%;
    object-fit: contain;
    pointer-events: none;
}
.token-circle img.token-watermark {
    inset: auto;
    opacity: .28; z-index: 1;
}
.token-circle .token-char {
    position: relative; z-index: 2;
    font-weight: 800; line-height: 1;
    pointer-events: none;
    text-shadow: 0 1px 3px rgba(0,0,0,.25);
    /* font-size + color set inline */
}
.token-circle .token-aspect-badge {
    position: absolute; top: 5%; left: 50%;
    transform: translateX(-50%);
    z-index: 3; line-height: 1;
    opacity: .85; pointer-events: none;
    /* font-size + color set inline */
}

/* --- Editor layout --- */
.editor-layout { display: flex; gap: 0; min-height: calc(100vh - 60px); }
.editor-left {
    flex: 1; padding: 1rem; overflow-y: auto;
    display: flex; flex-direction: column; align-items: center;
}
.editor-right {
    width: 400px; min-width: 400px;
    background: #16213e; border-left: 1px solid #2a2a4a;
    padding: 0 1rem 1rem; overflow-y: auto;
    max-height: calc(100vh - 60px);
}

/* --- Side panel tabs --- */
.panel-tabs {
    display: flex; gap: .4rem; margin: 0 -1rem 1rem;
    padding: .6rem 1rem 0; position: sticky; top: 0;
    background: #16213e; z-index: 10;
    border-bottom: 1px solid #2a2a4a;
}
.tab-btn {
    background: transparent; border: none; color: #aaa;
    padding: .5rem .9rem; font-size: .85rem; font-weight: 600;
    cursor: pointer; border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: #eee; }
.tab-btn.active { color: #e2c044; border-bottom-color: #e2c044; }
.side-panel { display: none; }
.side-panel.active { display: block; }

/* --- Token name --- */
.token-name-bar {
    display: flex; align-items: center; gap: .5rem;
    margin-bottom: 1rem; width: 100%; max-width: 700px;
}
.token-name-input {
    flex: 1; background: transparent; border: none; border-bottom: 2px solid #333;
    color: #e2c044; font-size: 1.2rem; font-weight: 700;
    padding: .3rem .5rem; font-family: 'Georgia', serif;
}
.token-name-input:focus { outline: none; border-bottom-color: #e2c044; }

/* --- Editor preview --- */
.token-preview {
    display: flex; gap: 3rem; flex-wrap: wrap;
    justify-content: center; align-items: flex-start;
    padding: 1.5rem 0;
}
.token-preview-side { text-align: center; }
.token-preview-side .side-label {
    color: #aaa; font-size: .8rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 2px;
    margin-bottom: .8rem;
}
.token-preview-side .qty-note { color: #667; font-size: .75rem; margin-top: .8rem; }

/* --- Panel sections & fields --- */
.panel-section {
    border: 1px solid #2a2a4a; border-radius: 10px;
    padding: .8rem; margin-bottom: 1rem; background: #131c36;
}
.panel-section h3 {
    margin: 0 0 .6rem; color: #e2c044; font-size: .8rem;
    text-transform: uppercase; letter-spacing: 1px;
}
.panel-section .section-hint { color: #778; font-size: .72rem; margin: -.3rem 0 .6rem; }

.editor-field { margin-bottom: .8rem; }
.editor-field:last-child { margin-bottom: 0; }
.editor-field label {
    display: block; color: #aaa; font-size: .72rem;
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: .3rem;
}
.editor-field input[type="text"],
.editor-field input[type="number"],
.editor-field textarea,
.editor-field select {
    width: 100%; padding: .5rem .7rem;
    background: #0f1629; border: 1px solid #333;
    color: #eee; border-radius: 6px; font-size: .85rem;
}
.editor-field textarea { resize: vertical; min-height: 70px; font-family: inherit; }
.editor-field input:focus, .editor-field textarea:focus, .editor-field select:focus {
    outline: none; border-color: #e2c044;
}

.color-field-row { display: flex; align-items: center; gap: .5rem; }
.color-field-row input[type="color"] {
    width: 42px; height: 32px; padding: 2px;
    background: #0f1629; border: 1px solid #333; border-radius: 6px;
    cursor: pointer; flex: 0 0 auto;
}
.color-field-row .color-note { color: #778; font-size: .72rem; flex: 1; }

.image-btn-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.image-status { color: #778; font-size: .72rem; }

/* Faction rows */
.faction-row {
    display: flex; gap: .4rem; align-items: center; margin-bottom: .45rem;
}
.faction-row input[type="color"] {
    width: 34px; height: 30px; padding: 2px;
    background: #0f1629; border: 1px solid #333; border-radius: 6px;
    cursor: pointer; flex: 0 0 auto;
}
.faction-row input[type="text"] {
    flex: 1; min-width: 0; padding: .4rem .6rem;
    background: #0f1629; border: 1px solid #333;
    color: #eee; border-radius: 6px; font-size: .82rem;
}
.faction-usage { color: #778; font-size: .68rem; min-width: 52px; text-align: right; }
.faction-col-labels {
    display: flex; gap: .4rem; color: #667; font-size: .62rem;
    text-transform: uppercase; letter-spacing: 1px; margin-bottom: .3rem;
}
.faction-col-labels span:first-child { width: 34px; }
.faction-col-labels span:nth-child(2) { width: 34px; }

/* --- Toasts --- */
.toast-container {
    position: fixed; top: 1.5rem; left: 50%; transform: translateX(-50%);
    z-index: 9999; display: flex; flex-direction: column; align-items: center; gap: .5rem;
}
.toast {
    padding: .7rem 1.2rem; border-radius: 8px; font-size: .85rem;
    animation: toastIn .3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.toast-success { background: #27ae60; color: #fff; }
.toast-error { background: #c0392b; color: #fff; }
.toast-info { background: #2980b9; color: #fff; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Confirm modal --- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 9998;
    background: rgba(10, 12, 26, .72);
    display: flex; align-items: center; justify-content: center;
}
.modal-card {
    background: #16213e; border: 1px solid #2a2a4a; border-radius: 14px;
    padding: 1.4rem 1.6rem; max-width: 420px; width: 92%;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.modal-card h3 { margin: 0 0 .5rem; color: #e2c044; font-size: 1.05rem; }
.modal-card p { margin: 0 0 1.2rem; color: #ccc; font-size: .88rem; line-height: 1.45; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; }

/* --- UV Print Sheet modal --- */
.sheet-card {
    max-width: 640px;
    max-height: 92vh; overflow-y: auto;
}
.sheet-card .section-hint { color: #99a; font-size: .8rem; line-height: 1.45; margin: 0 0 .8rem; }
.sheet-settings-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: .5rem .7rem; margin-bottom: .8rem;
}
.sheet-settings-grid label {
    display: flex; flex-direction: column; gap: .2rem;
    font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: #99a;
}
.sheet-settings-grid input {
    background: #0f1630; border: 1px solid #2a2a4a; border-radius: 6px;
    color: #eee; padding: .3rem .4rem; font-size: .85rem; width: 100%;
}
.sheet-counts {
    border: 1px solid #2a2a4a; border-radius: 8px;
    max-height: 32vh; overflow-y: auto; margin-bottom: .6rem;
}
.sheet-count-row {
    display: flex; align-items: center; gap: .6rem;
    padding: .35rem .6rem; border-bottom: 1px solid #232345;
}
.sheet-count-row:last-child { border-bottom: none; }
.sheet-count-name { flex: 1; font-size: .88rem; color: #eee; }
.sheet-count-bag { font-size: .75rem; color: #778; }
.sheet-count-row input {
    width: 4.2rem; background: #0f1630; border: 1px solid #2a2a4a;
    border-radius: 6px; color: #eee; padding: .25rem .4rem; font-size: .85rem;
}
.sheet-count-head {
    position: sticky; top: 0; background: #16213e; z-index: 1;
    padding-top: .45rem; padding-bottom: .25rem;
}
.sheet-count-head .sheet-count-col {
    width: 4.2rem; font-size: .65rem; text-transform: uppercase;
    letter-spacing: .04em; color: #99a; text-align: center;
}
.sheet-counts .empty-msg { color: #888; text-align: center; padding: 1rem; margin: 0; }
.sheet-total { font-size: .85rem; color: #8fc97f; margin-bottom: .4rem; }
.sheet-total.over { color: #e07a6a; font-weight: 700; }
.sheet-legend { font-size: .82rem; color: #aab; margin-bottom: .6rem; line-height: 1.5; }
.sheet-legend .legend-set { color: #e2c044; margin-right: .7rem; white-space: nowrap; }
.sheet-legend .legend-warn { color: #e0a06a; }

/* --- Responsive --- */
@media (max-width: 980px) {
    .editor-layout { flex-direction: column; }
    .editor-right { width: 100%; min-width: auto; border-left: none;
        border-top: 1px solid #2a2a4a; max-height: none; }
}
