    <div class="content" id="formations_panel">
        <h4 style="margin: 5px 0 10px 0;">Draw Formation</h4>
        <div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 5px;">
            <button class="btn btn-sm" onclick="UI.formations.startDrawing('support_resistance')">
                <span style="font-size: 18px;">━</span> Line
            </button>
            <button class="btn btn-sm" onclick="UI.formations.startDrawing('channel')">
                <span style="font-size: 18px;">═</span> Channel
            </button>
        </div>

        <!-- Drawing instructions (shown when drawing starts) -->
        <div id="formation_drawing_instructions" style="display: none; margin-top: 10px; padding: 10px; background: #2a2a2a; border-radius: 5px;">
            <div style="display: flex; justify-content: space-between; align-items: center;">
                <span id="formation_instruction_text" style="color: #8899aa; font-size: 12px;">Click on chart to place points...</span>
                <button class="btn btn-sm" style="background: #dc3545; padding: 4px 8px;" onclick="UI.formations.cancelDrawing()">Cancel</button>
            </div>
            <div style="margin-top: 8px; color: #667eea; font-size: 11px;">
                <span id="formation_points_status">Points: 0 / 2</span>
            </div>
        </div>

        <!-- Name input (shown after points are placed) -->
        <div id="formation_name_controls" style="display: none; margin-top: 10px; padding: 10px; background: #2a2a2a; border-radius: 5px;">
            <div style="margin-bottom: 8px; color: #28a745; font-size: 12px;">Points placed. Enter a name:</div>
            <div style="display: flex; gap: 10px; align-items: center;">
                <input type="text" id="formation_name_input" placeholder="Formation name"
                       style="flex: 1; padding: 5px; border-radius: 3px; border: 1px solid #444; background: #1e1e1e; color: #e0e0e0;">
                <button class="btn btn-sm" style="background: #28a745;" onclick="UI.formations.completeDrawing()">Save</button>
                <button class="btn btn-sm" style="background: #dc3545;" onclick="UI.formations.cancelDrawing()">Cancel</button>
            </div>
        </div>

        <hr>
        <h3>Formations</h3>
        <div class="formations-container" id="formations_list"></div>
    </div>

    <style>
        /* Formations container - flex grid for cards */
        .formations-container {
            display: flex;
            flex-wrap: wrap;
            gap: 15px;
            padding: 10px;
        }

        /* Individual formation card */
        .formation-item {
            position: relative;
            width: 100px;
            height: 100px;
            border-radius: 10px;
            background: linear-gradient(145deg, #2a3a5a, #1e2a40);
            box-shadow: 5px 5px 10px #151f30, -5px -5px 10px #253550;
            cursor: pointer;
            transition: all 0.3s ease;
            overflow: visible;
            border: 2px solid #3a5a8a;
        }

        .formation-item:hover {
            transform: translateY(-3px);
            box-shadow: 8px 8px 15px #151f30, -8px -8px 15px #253550;
            border-color: #667eea;
        }

        .formation-item.selected {
            border-color: #667eea;
            box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
        }

        /* Formation icon area */
        .formation-icon {
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            padding: 10px;
            position: relative;
        }

        /* CSS-based formation icon */
        .formation-icon::before {
            content: '';
            position: absolute;
            top: 10px;
            width: 40px;
            height: 40px;
            background: linear-gradient(135deg, #667eea 0%, #4a5cd8 100%);
            border-radius: 8px;
        }

        /* Line icon */
        .formation-item[data-type="support_resistance"] .formation-icon::after {
            content: '';
            position: absolute;
            top: 25px;
            width: 30px;
            height: 3px;
            background: white;
            transform: rotate(-15deg);
        }

        /* Channel icon - two parallel lines */
        .formation-item[data-type="channel"] .formation-icon::after {
            content: '';
            position: absolute;
            top: 20px;
            width: 28px;
            height: 3px;
            background: white;
            box-shadow: 0 10px 0 white;
            transform: rotate(-15deg);
        }

        /* Formation name */
        .formation-name {
            font-size: 11px;
            font-weight: bold;
            text-align: center;
            color: #e0e0e0;
            margin-top: 50px;
            word-wrap: break-word;
            max-width: 90px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* Formation type label */
        .formation-type {
            font-size: 9px;
            color: #8899aa;
            margin-top: 2px;
        }

        /* Delete button */
        .formation-item .delete-button {
            position: absolute;
            top: -8px;
            right: -8px;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            background: #dc3545;
            color: white;
            border: 2px solid #1e2a40;
            font-size: 12px;
            cursor: pointer;
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 10;
            transition: transform 0.2s;
        }

        .formation-item:hover .delete-button {
            display: flex;
        }

        .formation-item .delete-button:hover {
            transform: scale(1.2);
        }

        /* Edit button */
        .formation-item .edit-button {
            position: absolute;
            top: -8px;
            right: 18px;
            width: 22px;
            height: 22px;
            border-radius: 50%;
            background: #667eea;
            color: white;
            border: 2px solid #1e2a40;
            font-size: 11px;
            cursor: pointer;
            display: none;
            align-items: center;
            justify-content: center;
            z-index: 10;
            transition: transform 0.2s;
        }

        .formation-item:hover .edit-button {
            display: flex;
        }

        .formation-item .edit-button:hover {
            transform: scale(1.2);
        }

        /* Hover details panel */
        .formation-hover {
            position: absolute;
            top: 110px;
            left: 50%;
            transform: translateX(-50%);
            width: 180px;
            padding: 10px;
            background: #2a3a5a;
            border: 1px solid #4a6a9a;
            border-radius: 8px;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
            z-index: 100;
            display: none;
            font-size: 11px;
            color: #e0e0e0;
        }

        .formation-item:hover .formation-hover {
            display: block;
        }

        .formation-hover strong {
            display: block;
            margin-bottom: 8px;
            font-size: 13px;
            color: #e0e0e0;
            border-bottom: 1px solid #4a6a9a;
            padding-bottom: 5px;
        }

        .formation-details {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .formation-details span {
            color: #aabbcc;
        }

        /* Color indicator */
        .formation-color-dot {
            display: inline-block;
            width: 12px;
            height: 12px;
            border-radius: 50%;
            margin-right: 5px;
            vertical-align: middle;
        }

        /* Button styles */
        .btn-sm {
            padding: 8px 12px;
            font-size: 12px;
            border-radius: 5px;
            border: none;
            background: linear-gradient(145deg, #3a4a6a, #2a3a5a);
            color: #e0e0e0;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .btn-sm:hover {
            background: linear-gradient(145deg, #4a5a7a, #3a4a6a);
            transform: translateY(-1px);
        }

        .btn-sm:active {
            transform: translateY(0);
        }
    </style>
