/* ═══════════════════════════════════════════════════════════
   TipsYe Tactical Board — Premium Glassmorphism UI
   ═══════════════════════════════════════════════════════════ */

/* ─── Full-screen Layout ─── */
.tb-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 64px);
    min-height: 500px;
    overflow: hidden;
    border-radius: 16px;
    background: #0d1117;
}

/* ─── Canvas Stack ─── */
.tb-canvas-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tb-canvas-wrap canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 8px;
}

/* ─── Floating Panel Base ─── */
.tb-panel {
    position: absolute;
    z-index: 20;
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    background: rgba(15, 15, 25, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.04);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    color: #e2e8f0;
    font-size: 12px;
}
.tb-panel.collapsed {
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}
.tb-panel.collapsed-right {
    transform: translateX(110%);
    opacity: 0;
    pointer-events: none;
}

/* ─── Top Bar ─── */
.tb-topbar {
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 12px;
    white-space: nowrap;
}
.tb-topbar .tb-btn {
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

/* ─── Left Toolbar ─── */
.tb-left-tools {
    top: 50%;
    left: 12px;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 8px;
}
.tb-left-tools .tb-tool-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    background: transparent;
    color: #94a3b8;
}
.tb-left-tools .tb-tool-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border-color: rgba(255, 255, 255, 0.1);
}
.tb-left-tools .tb-tool-btn.active {
    background: rgba(68, 138, 255, 0.15);
    color: #448AFF;
    border-color: rgba(68, 138, 255, 0.3);
    box-shadow: 0 0 12px rgba(68, 138, 255, 0.15);
}
.tb-left-tools .tb-tool-btn svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
}

/* ─── Right Panel ─── */
.tb-right-panel {
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: 220px;
    padding: 14px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.tb-right-panel::-webkit-scrollbar {
    width: 4px;
}
.tb-right-panel::-webkit-scrollbar-track {
    background: transparent;
}
.tb-right-panel::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

/* ─── Panel Sections ─── */
.tb-section-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.tb-section-title::before {
    content: '';
    width: 3px;
    height: 12px;
    border-radius: 2px;
    background: linear-gradient(180deg, #448AFF, #00E676);
}

/* ─── Buttons ─── */
.tb-btn {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: #cbd5e1;
    transition: all 0.15s ease;
    white-space: nowrap;
    font-family: inherit;
}
.tb-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.tb-btn:active {
    transform: translateY(0);
}
.tb-btn.active {
    background: rgba(68, 138, 255, 0.12);
    border-color: rgba(68, 138, 255, 0.3);
    color: #448AFF;
}
.tb-btn.danger {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.2);
}
.tb-btn.danger:hover {
    background: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.4);
}
.tb-btn.primary {
    background: linear-gradient(135deg, rgba(68,138,255,0.2), rgba(0,230,118,0.1));
    border-color: rgba(68, 138, 255, 0.3);
    color: #60a5fa;
}
.tb-btn.primary:hover {
    background: linear-gradient(135deg, rgba(68,138,255,0.3), rgba(0,230,118,0.15));
    box-shadow: 0 0 16px rgba(68,138,255,0.15);
}

/* ─── Formation Select ─── */
.tb-formation-select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.tb-formation-select:focus {
    outline: none;
    border-color: rgba(68, 138, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(68, 138, 255, 0.1);
}
.tb-formation-select option {
    background: #1e1e2e;
    color: #e2e8f0;
}

/* ─── Color Swatches ─── */
.tb-color-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.tb-color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.15s ease;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.1);
}
.tb-color-swatch:hover {
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(255,255,255,0.2);
}
.tb-color-swatch.active {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255,255,255,0.3);
}

/* ─── Stroke Width ─── */
.tb-stroke-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.tb-stroke-btn {
    flex: 1;
    padding: 6px 0;
    text-align: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    color: #94a3b8;
    transition: all 0.15s ease;
}
.tb-stroke-btn:hover {
    background: rgba(255,255,255,0.08);
    color: #e2e8f0;
}
.tb-stroke-btn.active {
    background: rgba(68,138,255,0.12);
    border-color: rgba(68,138,255,0.3);
    color: #448AFF;
}

/* ─── Team Color Inputs ─── */
.tb-team-colors {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.tb-team-color-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.tb-team-color-item label {
    font-size: 10px;
    color: #94a3b8;
    white-space: nowrap;
}
.tb-team-color-item input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
    padding: 0;
}
.tb-team-color-item input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}
.tb-team-color-item input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.15);
}

/* ─── Theme Buttons ─── */
.tb-theme-row {
    display: flex;
    gap: 6px;
}
.tb-theme-btn {
    flex: 1;
    padding: 8px 6px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    font-size: 10px;
    font-weight: 600;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: #94a3b8;
    transition: all 0.15s ease;
}
.tb-theme-btn:hover {
    background: rgba(255,255,255,0.06);
    color: #e2e8f0;
}
.tb-theme-btn.active {
    border-color: rgba(0, 230, 118, 0.4);
    color: #00E676;
    background: rgba(0, 230, 118, 0.08);
}

/* ─── Toggle Button (Panel Show/Hide) ─── */
.tb-toggle-btn {
    position: absolute;
    z-index: 25;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: rgba(15, 15, 25, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    color: #94a3b8;
    transition: all 0.2s ease;
}
.tb-toggle-btn:hover {
    background: rgba(30, 30, 50, 0.9);
    color: #e2e8f0;
}
.tb-toggle-right {
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
}
.tb-toggle-right.panel-open {
    right: 240px;
}

/* ─── Separator ─── */
.tb-sep {
    width: 100%;
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 4px 0;
}

/* ─── Responsive: Tablet ─── */
@media (max-width: 1024px) {
    .tb-right-panel {
        width: 200px;
    }
}

/* ─── Responsive: Mobile ─── */
@media (max-width: 768px) {
    .tb-container {
        height: calc(100vh - 56px);
        border-radius: 0;
    }
    .tb-topbar {
        top: 8px;
        padding: 6px 10px;
        gap: 4px;
    }
    .tb-topbar .tb-btn {
        padding: 5px 8px;
        font-size: 10px;
    }
    .tb-left-tools {
        top: auto;
        bottom: 12px;
        left: 50%;
        transform: translateX(-50%) translateY(0);
        flex-direction: row;
        padding: 8px 12px;
    }
    .tb-left-tools .tb-tool-btn {
        width: 34px;
        height: 34px;
    }
    .tb-right-panel {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: auto;
        max-height: 45vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
        opacity: 0;
        pointer-events: none;
    }
    .tb-right-panel.open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: all;
    }
    .tb-toggle-right {
        bottom: 70px;
        top: auto;
        right: 12px;
        transform: none;
    }
    .tb-toggle-right.panel-open {
        right: 12px;
        bottom: calc(45vh + 12px);
    }
}

/* ─── Light Mode Overrides ─── */
html:not(.dark) .tb-container {
    background: #f0f4f8;
}
html:not(.dark) .tb-panel {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255,255,255,0.5);
    color: #1e293b;
}
html:not(.dark) .tb-btn {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.08);
    color: #475569;
}
html:not(.dark) .tb-btn:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #1e293b;
}
html:not(.dark) .tb-btn.active {
    background: rgba(68, 138, 255, 0.08);
    color: #2563eb;
}
html:not(.dark) .tb-left-tools .tb-tool-btn {
    color: #64748b;
}
html:not(.dark) .tb-left-tools .tb-tool-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #1e293b;
}
html:not(.dark) .tb-left-tools .tb-tool-btn.active {
    background: rgba(68, 138, 255, 0.1);
    color: #2563eb;
}
html:not(.dark) .tb-section-title {
    color: #94a3b8;
}
html:not(.dark) .tb-formation-select {
    background: rgba(0, 0, 0, 0.03);
    border-color: rgba(0, 0, 0, 0.1);
    color: #1e293b;
}
html:not(.dark) .tb-color-swatch {
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}
html:not(.dark) .tb-theme-btn {
    background: rgba(0,0,0,0.02);
    border-color: rgba(0,0,0,0.06);
    color: #64748b;
}
html:not(.dark) .tb-theme-btn.active {
    background: rgba(0, 230, 118, 0.06);
    border-color: rgba(0, 180, 90, 0.3);
    color: #059669;
}
html:not(.dark) .tb-toggle-btn {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0,0,0,0.08);
    color: #64748b;
}
