/* ═══════════════════════════════════════════════════════════════
   Tools menu in header
   ═══════════════════════════════════════════════════════════════ */
.tools-menu {
    position: relative;
}
.tools-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    cursor: pointer;
    transition: all var(--transition);
}
.tools-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent);
}
.tools-btn svg { display: block; }

.tools-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    min-width: 280px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 25;
}
.tools-dropdown button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-primary);
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.tools-dropdown button:hover {
    background: var(--bg-hover);
}
.tools-dropdown button.highlight {
    background: rgba(29,155,240,0.1);
    border: 1px solid rgba(29,155,240,0.3);
}
.tool-icon {
    font-size: 22px;
    flex-shrink: 0;
}
.tool-info {
    flex: 1;
    min-width: 0;
}
.tool-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.tool-desc {
    font-size: 11px;
    color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   EX-32 Modal
   ═══════════════════════════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.hidden { display: none; }

.ex32-modal-container {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}
.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}
.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: var(--bg-secondary);
    border-radius: 0 0 16px 16px;
}

/* Smart paste area */
.ex32-smart-paste {
    background: linear-gradient(135deg, rgba(29,155,240,0.05), rgba(0,186,124,0.05));
    border: 1px solid rgba(29,155,240,0.2);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 18px;
}
.ex32-smart-paste label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--accent);
}
.ex32-smart-paste textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
    min-height: 70px;
}
.ex32-smart-paste textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.ex32-smart-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 10px;
    gap: 10px;
}
.ex32-hint {
    font-size: 11px;
    color: var(--text-muted);
    flex: 1;
}
.btn-ai {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #1d9bf0, #00ba7c);
    color: #fff;
    border: none;
    border-radius: 20px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    flex-shrink: 0;
}
.btn-ai:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(29,155,240,0.3);
}
.btn-ai:disabled {
    opacity: 0.6;
    cursor: wait;
}
.btn-ai-icon { font-size: 14px; }

/* Tabs */
.ex32-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 18px;
    overflow-x: auto;
}
.ex32-tab {
    padding: 8px 14px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}
.ex32-tab:hover { color: var(--text-primary); }
.ex32-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.ex32-tab-content { display: none; }
.ex32-tab-content.active { display: block; }

/* Form sections */
.ex32-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 14px;
}
.ex32-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
    margin: 0 0 12px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.ex32-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.ex32-row:last-child { margin-bottom: 0; }
.ex32-row label {
    flex: 1;
    display: flex;
    flex-direction: column;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    min-width: 80px;
}
.ex32-row input,
.ex32-row select {
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
}
.ex32-row input:focus,
.ex32-row select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Checkboxes list */
.ex32-checks {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ex32-checks .check {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}
.ex32-checks .check:hover {
    background: var(--bg-hover);
}
.ex32-checks input[type="checkbox"] {
    margin-top: 2px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* Footer buttons */
.btn-primary, .btn-secondary {
    padding: 9px 18px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity 0.15s, transform 0.1s;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    opacity: 0.9;
}
.btn-primary:disabled {
    opacity: 0.6;
    cursor: wait;
}
.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: var(--bg-hover);
}

/* Mobile */
@media (max-width: 768px) {
    /* Modal overlay uses flex but let it scroll and position at top */
    .modal-overlay {
        padding: 0;
        align-items: stretch;
        justify-content: stretch;
    }

    .ex32-modal-container {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        height: 100dvh;  /* dynamic viewport height - accounts for mobile browser UI */
        border-radius: 0;
    }

    /* Header stays visible at the top */
    .modal-header {
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
        position: sticky;
        top: 0;
        background: var(--bg-primary);
        z-index: 2;
    }
    .modal-header h2 {
        font-size: 13px;
        line-height: 1.3;
        padding-right: 30px;  /* space for close button */
    }

    .modal-body {
        padding: 14px;
        padding-bottom: 20px;
    }

    /* Footer stays visible at bottom + respects safe area */
    .modal-footer {
        padding: 10px 14px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        flex-wrap: wrap;
        position: sticky;
        bottom: 0;
        background: var(--bg-secondary);
        z-index: 2;
    }
    .modal-footer button {
        flex: 1;
        min-width: 90px;
        padding: 10px 12px;
        font-size: 12px;
    }

    /* Form rows stack vertically on mobile */
    .ex32-row label { min-width: 100%; }
    .ex32-section { padding: 12px; }
    .ex32-tab { font-size: 12px; padding: 6px 10px; }

    /* Tools dropdown: anchor to LEFT on mobile (button is on left side of header) */
    .tools-dropdown {
        right: auto;
        left: 0;
        min-width: 220px;
        max-width: calc(100vw - 24px);
    }
    .tool-desc { display: none; }

    /* Smart paste area stack */
    .ex32-smart-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .btn-ai { width: 100%; justify-content: center; }
}
