/* =====================================================
   EDITOR DE MACROS — css/macros.css
   Paleta base del sitio:
     --bg-deep:     #080f1a
     --bg-card:     #0f1d2e
     --bg-input:    #060d16
     --accent-cyan: #73cdff
     --accent-mid:  #398bbd
     --accent-navy: #295a9c
     --text-primary:#c8dff0
     --text-muted:  #4a6a8a
   ===================================================== */

/* ── LAYOUT ─────────────────────────────────────────── */
.macro-app {
    display: grid;
    grid-template-columns: 260px 1fr;
    height: calc(100vh - 300px - 48px);
    min-height: 580px;
    background: #080f1a;
}

/* ── SIDEBAR ─────────────────────────────────────────── */
.macro-sidebar {
    background: #0a1526;
    border-right: 1px solid #295a9c44;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #295a9c44 transparent;
}
.macro-sidebar::-webkit-scrollbar { width: 4px; }
.macro-sidebar::-webkit-scrollbar-thumb { background: #295a9c44; border-radius: 2px; }

.macro-sb-section { padding: 12px 14px; border-bottom: 1px solid #295a9c33; }

.macro-sb-label {
    display: block;
    font-size: 10px;
    font-weight: 600;
    color: #4a6a8a;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.macro-name-input {
    width: 100%;
    background: #060d16;
    border: 1px solid #295a9c44;
    color: #c8dff0;
    padding: 6px 9px;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    font-family: 'Pokemon', monospace;
}
.macro-name-input:focus { border-color: #73cdff; }

.macro-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.macro-info-card {
    background: #060d16;
    border: 1px solid #295a9c33;
    border-radius: 4px;
    padding: 7px 9px;
}
.macro-info-label { font-size: 10px; color: #4a6a8a; }
.macro-info-val { font-size: 14px; font-weight: 600; color: #73cdff; font-family: monospace; margin-top: 2px; }

.macro-file-row { display: flex; gap: 5px; flex-wrap: wrap; }
.macro-file-row .macro-btn { flex: 1; justify-content: center; min-width: 80px; }

.macro-template-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: 1px solid #295a9c44;
    border-radius: 4px;
    color: #c8dff0;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.12s;
    margin-bottom: 5px;
    text-align: left;
}
.macro-template-btn:last-child { margin-bottom: 0; }
.macro-template-btn:hover { border-color: #73cdff; color: #73cdff; background: rgba(115,205,255,0.06); }
.macro-tpl-icon { font-size: 15px; flex-shrink: 0; }
.macro-tpl-title { font-weight: 600; font-size: 12px; }
.macro-tpl-sub { font-size: 10px; color: #4a6a8a; margin-top: 1px; }
.macro-template-btn:hover .macro-tpl-sub { color: rgba(115,205,255,0.6); }

.macro-clip-info { font-size: 11px; color: #4a6a8a; margin-bottom: 6px; font-family: monospace; }

.macro-shortcuts { font-size: 11px; color: #4a6a8a; line-height: 1.8; }
.macro-shortcuts kbd {
    background: #060d16;
    border: 1px solid #295a9c44;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 10px;
    color: #73cdff;
    font-family: monospace;
    margin-right: 4px;
}

/* ── BUTTONS (sidebar/toolbar) ───────────────────────── */
.macro-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #295a9c44;
    background: #0f1d2e;
    color: #c8dff0;
    transition: all 0.12s;
    white-space: nowrap;
    font-family: 'Pokemon', monospace;
}
.macro-btn:hover { border-color: #295a9c88; background: #1a2e4a; }
.macro-btn:active { transform: scale(0.97); }
.macro-btn svg { width: 12px; height: 12px; flex-shrink: 0; }

.macro-btn-primary { background: rgba(115,205,255,0.08); border-color: #73cdff66; color: #73cdff; }
.macro-btn-primary:hover { background: rgba(115,205,255,0.15); border-color: #73cdff; }
.macro-btn-danger { background: rgba(248,81,73,0.08); border-color: #f8514966; color: #f85149; }
.macro-btn-danger:hover { background: rgba(248,81,73,0.15); border-color: #f85149; }

/* ── TOOLBAR ─────────────────────────────────────────── */
.macro-editor { display: flex; flex-direction: column; overflow: hidden; background: #080f1a; }

.macro-toolbar {
    padding: 8px 14px;
    border-bottom: 1px solid #295a9c44;
    background: #0a1526;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}
.macro-tb-label { font-size: 10px; color: #4a6a8a; text-transform: uppercase; letter-spacing: 0.08em; flex-shrink: 0; }
.macro-tb-sep { width: 1px; height: 22px; background: #295a9c44; flex-shrink: 0; }

/* ── GAMEPAD BUTTONS (TOOLBAR PALETTE) ───────────────── */
.macro-btn-palette { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }

.macro-gp-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 2px solid #398bbd;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: #c8dff0;
    background: #0f1d2e;
    transition: all 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: 'Pokemon', monospace;
}
.macro-gp-sq { border-radius: 50%; }
.macro-gp-btn:hover { background: #295a9c; border-color: #73cdff; color: #73cdff; transform: scale(1.1); }
.macro-gp-btn:active { transform: scale(0.92); }
.macro-gp-btn.macro-gp-active { background: #1d3a5c; border-color: #73cdff; color: #73cdff; outline: 2px solid #73cdff; outline-offset: 2px; }

.macro-dur-wrap { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.macro-dur-wrap label { font-size: 11px; color: #4a6a8a; }
.macro-dur-wrap input {
    width: 66px;
    background: #060d16;
    border: 1px solid #295a9c44;
    color: #c8dff0;
    padding: 4px 7px;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    font-family: monospace;
}
.macro-dur-wrap input:focus { border-color: #73cdff; }
.macro-dur-wrap span { font-size: 11px; color: #4a6a8a; }

.macro-insert-pill {
    display: none;
    align-items: center;
    gap: 6px;
    background: rgba(115,205,255,0.08);
    border: 1px solid #73cdff66;
    color: #73cdff;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-family: 'Pokemon', monospace;
}
.macro-insert-pill.on { display: flex; }
.macro-insert-pill button { background: none; border: none; color: #73cdff; cursor: pointer; font-size: 14px; line-height: 1; padding: 0; }

/* ── SEQUENCE AREA ───────────────────────────────────── */
.macro-seq-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    scrollbar-width: thin;
    scrollbar-color: #295a9c44 transparent;
}
.macro-seq-area::-webkit-scrollbar { width: 4px; }
.macro-seq-area::-webkit-scrollbar-thumb { background: #295a9c44; border-radius: 2px; }

.macro-seq-empty {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #2a4a6a;
}
.macro-seq-empty svg { width: 44px; height: 44px; opacity: 0.3; }
.macro-seq-empty p { font-size: 13px; color: #4a6a8a; font-family: 'Pokemon', monospace; }
.macro-seq-empty small { font-size: 11px; color: #2a4a6a; text-align: center; line-height: 1.6; }

/* ── SEQUENCE LIST ───────────────────────────────────── */
/* Layout: los pasos van en línea como la app oficial */
.macro-seq-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    padding-bottom: 20px;
    row-gap: 16px;
}

/* ── STEP — layout horizontal tipo app oficial ────────── */
/* Cada step = [círculo] [bloque-tiempo] en fila */
.macro-step {
    position: relative;
    display: flex;
    flex-direction: row;
    align-items: center;
    margin: 2px 0;
}
.macro-step:hover .macro-step-del { opacity: 1; }
.macro-step:hover .macro-ins-before { display: flex; }

/* Círculo del botón — siempre circular */
.macro-step-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.12s;
    flex-shrink: 0;
    font-family: 'Pokemon', monospace;
    position: relative;
}
.macro-step-circle.macro-sq { border-radius: 50%; }

/* PRESS: fondo sólido */
.macro-step-circle.macro-press {
    background: #1d3a5c;
    border: 2px solid #398bbd;
    color: #c8dff0;
}
/* RELEASE: solo borde, fondo transparente */
.macro-step-circle.macro-release {
    background: transparent;
    border: 2px solid #295a9c;
    color: #4a6a8a;
}

/* Seleccionado */
.macro-step-circle.macro-sel {
    box-shadow: 0 0 0 2px #73cdff, 0 0 10px rgba(115,205,255,0.2);
    border-color: #73cdff !important;
    color: #73cdff !important;
}

/* Bloque de tiempo a la DERECHA del círculo */
.macro-step-dur {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 5px;
    margin-right: 4px;
    cursor: text;
    min-width: 32px;
    padding: 2px 3px;
    border-radius: 3px;
    border: 1px solid transparent;
    transition: border-color 0.12s;
}
.macro-step-dur:hover { border-color: #295a9c44; }

/* Número de duración */
.macro-step-dur .dur-num {
    font-size: 14px;
    font-weight: 600;
    color: #c8dff0;
    font-family: monospace;
    line-height: 1.2;
    white-space: nowrap;
}

/* Línea decorativa horizontal (como en la app oficial) */
.macro-step-dur .dur-line {
    display: block;
    width: 100%;
    height: 1px;
    background: #295a9c66;
    margin: 2px 0;
}

/* Texto "ms" */
.macro-step-dur .dur-ms {
    font-size: 11px;
    color: #4a6a8a;
    font-family: monospace;
    line-height: 1.2;
}

/* Input inline para editar duración */
.macro-step-dur-input {
    width: 52px;
    background: #060d16;
    border: 1px solid #73cdff;
    color: #73cdff;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 11px;
    font-family: monospace;
    outline: none;
    text-align: center;
    margin-left: 5px;
    flex-shrink: 0;
    align-self: center;
}

/* Botón eliminar */
.macro-step-del {
    opacity: 0;
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #dc2626;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    transition: opacity 0.12s;
    z-index: 5;
    line-height: 1;
}
.macro-step-del:hover { transform: scale(1.2); }

/* Insertar antes */
.macro-ins-before {
    display: none;
    position: absolute;
    left: -10px;
    top: 14px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(115,205,255,0.1);
    border: 1px dashed #73cdff66;
    color: #73cdff;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    z-index: 4;
    transition: all 0.12s;
}
.macro-ins-before:hover { background: #73cdff; color: #080f1a; border-color: #73cdff; }

/* ── SELECTION BAR ───────────────────────────────────── */
.macro-sel-bar {
    flex-shrink: 0;
    padding: 7px 16px;
    border-top: 1px solid #295a9c44;
    background: #0a1526;
    display: none;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.macro-sel-bar.on { display: flex; }
.macro-sel-info { font-size: 12px; color: #4a6a8a; font-family: 'Pokemon', monospace; }
.macro-sel-edit { display: flex; align-items: center; gap: 6px; }
.macro-sel-edit label { font-size: 11px; color: #4a6a8a; }
.macro-sel-edit input {
    width: 65px;
    background: #060d16;
    border: 1px solid #295a9c44;
    color: #c8dff0;
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
    font-family: monospace;
}
.macro-sel-edit input:focus { border-color: #73cdff; }

/* ── MODAL ───────────────────────────────────────────── */
.macro-modal-bg { position: fixed; inset: 0; background: rgba(6,13,22,0.75); display: none; align-items: center; justify-content: center; z-index: 9999; }
.macro-modal-bg.on { display: flex; }
.macro-modal { background: #0f1d2e; border: 1px solid #295a9c66; border-radius: 8px; padding: 24px; width: 340px; max-width: 90vw; }
.macro-modal h3 { font-size: 14px; color: #73cdff; margin-bottom: 10px; font-family: 'Pokemon', monospace; }
.macro-modal p { font-size: 12px; color: #4a6a8a; line-height: 1.6; margin-bottom: 18px; }
.macro-modal-actions { display: flex; gap: 7px; justify-content: flex-end; }

/* ── TOAST ───────────────────────────────────────────── */
#macroToast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #0f1d2e;
    border: 1px solid #295a9c66;
    color: #c8dff0;
    padding: 9px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Pokemon', monospace;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.18s;
    pointer-events: none;
    max-width: 280px;
}
#macroToast.on  { opacity: 1; }
#macroToast.ok  { border-color: #a2de7a66; color: #a2de7a; }
#macroToast.err { border-color: #f8514966; color: #f85149; }

/* ── WEBHID ───────────────────────────────────────────── */
.macro-hid-status {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: #4a6a8a;
    margin-bottom: 8px;
    font-family: 'Pokemon', monospace;
}
.hid-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.hid-dot-off  { background: #374151; box-shadow: none; }
.hid-dot-warn { background: #e3b341; box-shadow: 0 0 6px rgba(227,179,65,0.5); }
.hid-dot-on  {
    background: #a2de7a;
    box-shadow: 0 0 6px rgba(162,222,122,0.6);
    animation: hid-pulse 2s infinite;
}
@keyframes hid-pulse {
    0%,100% { opacity: 1; } 50% { opacity: 0.6; }
}

.macro-btn-hid {
    flex: 1;
    justify-content: center;
    font-size: 11px;
    padding: 5px 4px;
    gap: 4px;
    background: rgba(115,205,255,0.06);
    border-color: #295a9c66;
    color: #73cdff;
}
.macro-btn-hid:hover {
    background: rgba(115,205,255,0.15);
    border-color: #73cdff;
}

.hid-profile-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #295a9c;
    font-size: 9px;
    font-weight: 700;
    color: #c8dff0;
    flex-shrink: 0;
}

.macro-hid-progress {
    margin-top: 6px;
}
.hid-progress-bar {
    height: 4px;
    background: #0f1d2e;
    border-radius: 2px;
    overflow: hidden;
    border: 1px solid #295a9c33;
    margin-bottom: 5px;
}
.hid-progress-fill {
    height: 100%;
    background: #73cdff;
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}
.hid-progress-msg {
    font-size: 10px;
    color: #4a6a8a;
    font-family: 'Pokemon', monospace;
    text-align: center;
}

.macro-hid-note {
    font-size: 10px;
    color: #4a6a8a;
    line-height: 1.6;
    margin-bottom: 6px;
}
.macro-hid-note strong {
    color: #73cdff;
    font-weight: 600;
}

/* Botón HID seleccionado */
.macro-btn-hid.macro-hid-sel {
    background: rgba(115,205,255,0.18);
    border-color: #73cdff;
    color: #73cdff;
}
