/* ============================================================
   TACTICS BOARD BUILDER — Styles
   ============================================================ */

/* --- Password Gate (same as card builder) --- */
.password-gate {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: #1a1a2e; z-index: 9999;
}
.password-form-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);
}
.password-form-card h1 { color: #e2c044; margin: 0 0 .25rem; font-size: 1.6rem; }
.password-form-card .subtitle { color: #aaa; margin: 0 0 1.5rem; font-size: .9rem; }
.form-group { margin-bottom: 1rem; text-align: left; }
.form-label { display: block; color: #ccc; font-size: .8rem; margin-bottom: .3rem; }
.form-control {
    width: 100%; padding: .6rem .8rem; border: 1px solid #333;
    border-radius: 8px; background: #0f1629; color: #eee;
    font-size: .95rem; box-sizing: border-box;
}
.auth-error { color: #f44; margin: .5rem 0; font-size: .85rem; }

/* --- 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;
}
.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-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #2ecc71; }
.btn-full { width: 100%; }
.btn-sm { padding: .35rem .8rem; font-size: .78rem; }

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

.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.3rem; margin: 0;
    font-family: 'Georgia', serif;
}
.app-header .header-actions {
    display: flex; gap: .5rem; margin-left: auto; align-items: center; flex-wrap: wrap;
}

/* --- Board List View --- */
.view-panel { display: none; }
.view-panel.active { display: block; }

.board-list {
    padding: 1.5rem; max-width: 900px; margin: 0 auto;
}
.board-list-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem;
}
.board-list-header h2 { margin: 0; color: #e2c044; }
.board-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.board-card {
    background: #16213e; border-radius: 12px; padding: 1.2rem;
    border: 1px solid #2a2a4a; cursor: pointer;
    transition: all .15s;
}
.board-card:hover { border-color: #e2c044; transform: translateY(-2px); }
.board-card h3 { margin: 0 0 .4rem; color: #eee; font-size: 1.1rem; }
.board-card .board-meta { color: #888; font-size: .8rem; }
.board-card .board-actions { margin-top: .8rem; display: flex; gap: .5rem; }

/* --- Editor View --- */
.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: 380px; min-width: 380px;
    background: #16213e; border-left: 1px solid #2a2a4a;
    padding: 1rem; overflow-y: auto;
}

/* --- Visual Board Preview --- */
.board-preview-wrapper {
    width: 100%; max-width: 750px;
}
.board-preview {
    /* Scaled representation of 8.5 x 11 board */
    width: 100%;
    aspect-ratio: 11 / 8.5;
    background: #111;
    border-radius: 12px;
    border: 2px solid #333;
    position: relative;
    overflow: hidden;
    padding: 2%;
    box-sizing: border-box;
}

/* Row labels and backgrounds */
.board-row {
    display: flex;
    align-items: center;
    border-radius: 8px;
    padding: 4px 6px;
    margin-bottom: 6px;
    position: relative;
    height: 22%;
}
.board-row.row-might { background: #c0392b; }
.board-row.row-mind { background: #2980b9; }
.board-row.row-spirit { background: #27ae60; }

.board-row-label {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-weight: 800;
    font-size: .75rem;
    color: #fff;
    text-transform: uppercase;
    margin-right: 6px;
    letter-spacing: 2px;
    min-width: 20px;
    text-align: center;
}

.board-spaces {
    display: flex;
    gap: 4px;
    flex: 1;
    justify-content: space-around;
    align-items: center;
    height: 100%;
}

/* --- Token Space Circles --- */
.token-space {
    width: 12%;
    aspect-ratio: 1;
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    transition: all .15s;
    box-shadow: 0 2px 6px rgba(0,0,0,.4);
    overflow: hidden;
    border: 2px solid rgba(255,255,255,.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.token-space:hover {
    transform: scale(1.12);
    border-color: #e2c044;
    box-shadow: 0 0 12px rgba(226,192,68,.5);
    z-index: 5;
}
.token-space.selected {
    border-color: #e2c044;
    box-shadow: 0 0 16px rgba(226,192,68,.7);
    transform: scale(1.15);
    z-index: 5;
}

/* Space type colors */
.token-space.type-single_purple { background: #8e44ad; }
.token-space.type-single_yellow { background: #f1c40f; }
.token-space.type-split {
    background: linear-gradient(to bottom, #f1c40f 50%, #8e44ad 50%);
}

/* Text inside token spaces */
.token-space-letter {
    position: absolute;
    top: 1px; left: 50%;
    transform: translateX(-50%);
    font-size: .5rem;
    font-weight: 700;
    color: rgba(0,0,0,.6);
    text-transform: uppercase;
    z-index: 2;
    pointer-events: none;
}
.token-space-text {
    line-height: 1.1;
    text-align: center;
    color: #000;
    font-weight: 600;
    overflow-wrap: break-word;
    word-break: normal;
    hyphens: none;
    overflow: hidden;
    pointer-events: none;
    /* font-size set dynamically by JS autoFitText() */
}
/* Split: top half (yellow) — sits in top 50% of circle, inset from edges */
.token-space-text.text-top {
    position: absolute;
    top: 14%;
    left: 10%;
    right: 10%;
    bottom: 52%;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Split: bottom half (purple) — sits in bottom 50% of circle, inset from edges */
.token-space-text.text-bottom {
    position: absolute;
    top: 52%;
    left: 10%;
    right: 10%;
    bottom: 6%;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Single effect: centered in full circle */
.token-space-text.text-center {
    position: absolute;
    top: 10%;
    left: 10%;
    right: 10%;
    bottom: 10%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Space Editor Panel --- */
.space-editor-title {
    font-size: 1.1rem; color: #e2c044; margin: 0 0 1rem;
    display: flex; align-items: center; gap: .5rem;
}
.space-editor-title .space-letter {
    display: inline-flex; width: 28px; height: 28px;
    border-radius: 50%; background: #e2c044; color: #1a1a2e;
    align-items: center; justify-content: center;
    font-weight: 800; font-size: .9rem;
}
.editor-field { margin-bottom: 1rem; }
.editor-field label {
    display: block; color: #aaa; font-size: .75rem;
    text-transform: uppercase; letter-spacing: 1px;
    margin-bottom: .3rem;
}
.editor-field select,
.editor-field input,
.editor-field textarea {
    width: 100%; padding: .5rem .7rem;
    background: #0f1629; border: 1px solid #333;
    color: #eee; border-radius: 6px; font-size: .85rem;
    box-sizing: border-box;
}
.editor-field textarea { resize: vertical; min-height: 60px; }

/* Space type preview buttons */
.space-type-options {
    display: flex; gap: .5rem; margin-top: .3rem;
}
.space-type-btn {
    flex: 1; padding: .6rem; border: 2px solid #333;
    border-radius: 8px; cursor: pointer; text-align: center;
    font-size: .7rem; font-weight: 600; transition: all .15s;
    background: #0f1629;
}
.space-type-btn:hover { border-color: #e2c044; }
.space-type-btn.active { border-color: #e2c044; box-shadow: 0 0 8px rgba(226,192,68,.3); }

.space-type-btn .type-preview {
    width: 36px; height: 36px; border-radius: 50%;
    margin: 0 auto .3rem; border: 1px solid rgba(255,255,255,.2);
}
.space-type-btn .type-preview.preview-purple { background: #8e44ad; }
.space-type-btn .type-preview.preview-yellow { background: #f1c40f; }
.space-type-btn .type-preview.preview-split {
    background: linear-gradient(to bottom, #f1c40f 50%, #8e44ad 50%);
}

.space-type-btn .type-label { color: #ccc; }

/* Effect autocomplete */
.effect-input-wrapper { position: relative; }
.effect-suggestions {
    position: absolute; top: 100%; left: 0; right: 0;
    background: #16213e; border: 1px solid #333;
    border-radius: 0 0 6px 6px; max-height: 180px;
    overflow-y: auto; z-index: 20; display: none;
}
.effect-suggestions.open { display: block; }
.effect-suggestion {
    padding: .5rem .7rem; cursor: pointer; font-size: .8rem;
    border-bottom: 1px solid #222;
}
.effect-suggestion:hover { background: #1e3055; }
.effect-suggestion .eff-cat {
    color: #888; font-size: .7rem; margin-left: .5rem;
}

/* No space selected state */
.no-space-selected {
    text-align: center; color: #666; padding: 3rem 1rem;
}
.no-space-selected .icon { font-size: 3rem; margin-bottom: .5rem; }

/* --- Board Name Input --- */
.board-name-bar {
    display: flex; align-items: center; gap: .5rem;
    margin-bottom: .8rem; width: 100%; max-width: 750px;
}
.board-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;
}
.board-name-input:focus { outline: none; border-bottom-color: #e2c044; }

/* --- 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: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

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

/* ============================================================
   PRINT STYLES — 8.5 x 11 inches, landscape
   ============================================================ */
@media print {
    body { background: #fff; color: #000; margin: 0; padding: 0; }
    .password-gate, .app-header, .editor-right,
    .board-name-bar, .header-actions, .toast-container,
    .board-list, .no-space-selected { display: none !important; }

    #main-app, .view-panel.active, .editor-layout, .editor-left {
        display: block !important;
        padding: 0 !important; margin: 0 !important;
    }

    .board-preview-wrapper { max-width: none; }
    .board-preview {
        width: 10in;
        height: 7.5in;
        border: 2px solid #000;
        border-radius: 0;
        page-break-inside: avoid;
    }
    .board-row { height: 1.8in; }
    .token-space {
        width: 1in; height: 1in;
        border: 2px solid #000;
    }
    .token-space-text { font-size: 7pt; }
    .token-space-letter { font-size: 6pt; }
}
